-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Daria Pardue <[email protected]>
- Loading branch information
Showing
15 changed files
with
528 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
|
||
const { expect } = require('chai'); | ||
const { AggregateOperation } = require('../../../src/operations/aggregate'); | ||
|
||
describe('AggregateOperation', function () { | ||
const db = 'test'; | ||
|
||
describe('#constructor', function () { | ||
context('when out is in the options', function () { | ||
const operation = new AggregateOperation(db, [], { out: 'test', dbName: db }); | ||
|
||
it('sets trySecondaryWrite to true', function () { | ||
expect(operation.trySecondaryWrite).to.be.true; | ||
}); | ||
}); | ||
|
||
context('when $out is the last stage', function () { | ||
const operation = new AggregateOperation(db, [{ $out: 'test' }], { dbName: db }); | ||
|
||
it('sets trySecondaryWrite to true', function () { | ||
expect(operation.trySecondaryWrite).to.be.true; | ||
}); | ||
}); | ||
|
||
context('when $out is not the last stage', function () { | ||
const operation = new AggregateOperation(db, [{ $out: 'test' }, { $project: { name: 1 } }], { | ||
dbName: db | ||
}); | ||
|
||
it('sets trySecondaryWrite to false', function () { | ||
expect(operation.trySecondaryWrite).to.be.false; | ||
}); | ||
}); | ||
|
||
context('when $merge is the last stage', function () { | ||
const operation = new AggregateOperation(db, [{ $merge: { into: 'test' } }], { dbName: db }); | ||
|
||
it('sets trySecondaryWrite to true', function () { | ||
expect(operation.trySecondaryWrite).to.be.true; | ||
}); | ||
}); | ||
|
||
context('when $merge is not the last stage', function () { | ||
const operation = new AggregateOperation( | ||
db, | ||
[{ $merge: { into: 'test' } }, { $project: { name: 1 } }], | ||
{ dbName: db } | ||
); | ||
|
||
it('sets trySecondaryWrite to false', function () { | ||
expect(operation.trySecondaryWrite).to.be.false; | ||
}); | ||
}); | ||
|
||
context('when no writable stages in empty pipeline', function () { | ||
const operation = new AggregateOperation(db, [], { dbName: db }); | ||
|
||
it('sets trySecondaryWrite to false', function () { | ||
expect(operation.trySecondaryWrite).to.be.false; | ||
}); | ||
}); | ||
|
||
context('when no writable stages', function () { | ||
const operation = new AggregateOperation(db, [{ $project: { name: 1 } }], { dbName: db }); | ||
|
||
it('sets trySecondaryWrite to false', function () { | ||
expect(operation.trySecondaryWrite).to.be.false; | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.