(
testCommand: (db: Db, collection: Collection) => Promise<unknown>
)
| 759 | ); |
| 760 | |
| 761 | function commitQuorumTest( |
| 762 | testCommand: (db: Db, collection: Collection) => Promise<unknown> |
| 763 | ): any { |
| 764 | return { |
| 765 | metadata: { requires: { mongodb: class="st">'>=4.4', topology: [class="st">'replicaset', class="st">'sharded'] } }, |
| 766 | test: async function () { |
| 767 | const events: CommandStartedEvent[] = []; |
| 768 | client.on(class="st">'commandStarted', event => { |
| 769 | if (event.commandName === class="st">'createIndexes') events.push(event); |
| 770 | }); |
| 771 | |
| 772 | const db = client.db(class="st">'test'); |
| 773 | const collection = db.collection(class="st">'commitQuorum'); |
| 774 | await collection.insertOne({ a: 1 }); |
| 775 | await testCommand(db, collection); |
| 776 | |
| 777 | expect(events).to.be.an(class="st">'array').with.lengthOf(1); |
| 778 | expect(events[0]).nested.property(class="st">'command.commitQuorum').to.equal(0); |
| 779 | await collection.drop(); |
| 780 | } |
| 781 | }; |
| 782 | } |
| 783 | it( |
| 784 | class="st">'should run command with commitQuorum if specified on db.createIndex', |
| 785 | commitQuorumTest( |
no test coverage detected