mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-24 00:17:37 +01:00
65a540a725
GitOrigin-RevId: 02cc4ab1ec84d4069ac6fe862c6e442340b5e481
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
/**
|
|
* Test that hello and its aliases, ismaster and isMaster, are all accepted
|
|
* by mongotmock and that the appropriate response fields are returned.
|
|
*/
|
|
import {MongotMock} from "jstests/with_mongot/mongotmock/lib/mongotmock.js";
|
|
|
|
// Set up mongotmock.
|
|
const mongotmock = new MongotMock();
|
|
mongotmock.start();
|
|
const mongotConn = mongotmock.getConnection();
|
|
|
|
function checkResponseFields(commandString) {
|
|
jsTestLog("Testing " + commandString + " for MongotMock");
|
|
const commandResponse = assert.commandWorked(mongotConn.adminCommand(commandString));
|
|
assert.eq(commandResponse.ismongot,
|
|
true,
|
|
"ismongot is not true, command response: " + tojson(commandResponse));
|
|
|
|
if (commandString === "hello") {
|
|
assert.eq(commandResponse.ismaster,
|
|
undefined,
|
|
"ismaster is not undefined, command response: " + tojson(commandResponse));
|
|
assert.eq(commandResponse.isWritablePrimary,
|
|
true,
|
|
"isWritablePrimary is not true, command response: " + tojson(commandResponse));
|
|
} else {
|
|
assert.eq(commandResponse.ismaster,
|
|
true,
|
|
"ismaster is not true, command response: " + tojson(commandResponse));
|
|
assert.eq(
|
|
commandResponse.isWritablePrimary,
|
|
undefined,
|
|
"isWritablePrimary is not undefined, command response: " + tojson(commandResponse));
|
|
}
|
|
}
|
|
|
|
checkResponseFields("ismaster");
|
|
checkResponseFields("isMaster");
|
|
checkResponseFields("hello");
|
|
|
|
mongotmock.stop();
|