MCPcopy
hub / github.com/mongodb/node-mongodb-native / run

Method run

test/unit/assorted/write_concern.test.js:52–94  ·  view source on GitHub ↗
(resultKey, testFn)

Source from the content-addressed store, hash-verified

50 }
51
52 async run(resultKey, testFn) {
53 const self = this;
54 let primaryServer = await mock.createServer(32000, 'localhost');
55 let firstSecondaryServer = await mock.createServer(32001, 'localhost');
56 let arbiterServer = await mock.createServer(32002, 'localhost');
57
58 primaryServer.setMessageHandler(request => {
59 const doc = request.document;
60 if (isHello(doc)) {
61 request.reply(self.serverStates.primary[0]);
62 } else if (doc[resultKey]) {
63 self.commandResult = doc;
64 request.reply(Object.assign({ ok: 1 }, self.responseDecoration));
65 } else if (doc.endSessions) {
66 request.reply({ ok: 1 });
67 }
68 });
69
70 firstSecondaryServer.setMessageHandler(request => {
71 const doc = request.document;
72 if (isHello(doc)) {
73 request.reply(self.serverStates.firstSecondary[0]);
74 } else if (doc.endSessions) {
75 request.reply({ ok: 1 });
76 }
77 });
78
79 arbiterServer.setMessageHandler(request => {
80 const doc = request.document;
81 if (isHello(doc)) {
82 request.reply(self.serverStates.arbiter[0]);
83 } else if (doc.endSessions) {
84 request.reply({ ok: 1 });
85 }
86 });
87
88 const client = new MongoClient(
89 'mongodb://localhost:32000,localhost:32001,localhost:32002/test?replicaSet=rs'
90 );
91
92 await client.connect();
93 await testFn(client, client.db('write_concern_db'));
94 }
95}
96
97function writeConcernTest(command, testFn) {

Callers 1

writeConcernTestFunction · 0.95

Calls 4

connectMethod · 0.95
dbMethod · 0.95
setMessageHandlerMethod · 0.80
isHelloFunction · 0.50

Tested by

no test coverage detected