0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/jstests/noPassthrough/shell_interactive.js
Asya Kamsky 801fb6ac59 SERVER-36196 expose function isInteractive() for determining if shell is running in interactive mode.
Signed-off-by: Max Hirschhorn <max.hirschhorn@mongodb.com>
2018-08-15 10:58:45 -04:00

25 lines
948 B
JavaScript

// Test that isInteractive() returns false when running script or --eval
// and true when running in interactive mode
(function() {
"use strict";
if (!_isWindows()) {
clearRawMongoProgramOutput();
var rc = runProgram("./mongo", "--nodb", "--quiet", "--eval", "print(isInteractive())");
assert.eq(rc, 0);
var output = rawMongoProgramOutput();
var response = (output.split('\n').slice(-2)[0]).split(' ')[1];
assert.eq(response, "false", "Expected 'false' in script mode");
// now try interactive
clearRawMongoProgramOutput();
rc = runProgram(
"./mongo", "--nodb", "--quiet", "--shell", "--eval", "print(isInteractive()); quit()");
assert.eq(rc, 0);
output = rawMongoProgramOutput();
response = (output.split('\n').slice(-2)[0]).split(' ')[1];
assert.eq(response, "true", "Expected 'true' in interactive mode");
}
})();