summaryrefslogtreecommitdiff
path: root/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js')
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js
new file mode 100644
index 00000000000..0cd8bca00a9
--- /dev/null
+++ b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js
@@ -0,0 +1,37 @@
+// mongofiles_invalid.js; runs mongofiles with an invalid command and
+// option - ensures it fails in all cases
+var testName = 'mongofiles_invalid';
+load('jstests/files/util/mongofiles_common.js');
+(function() {
+ jsTest.log('Testing mongofiles with invalid commands and options');
+
+ var runTests = function(topology, passthrough) {
+ var t = topology.init(passthrough);
+ var conn = t.connection();
+
+ jsTest.log('Running with file with invalid options onw passthrough ' + passthrough.name);
+
+ // run with invalid option
+ assert.neq(runMongoProgram.apply(this, ['mongofiles',
+ '--invalid', conn.port,
+ 'put', filesToInsert[0]]
+ .concat(passthrough.args)),
+ 0, 'invalid-option: mongofiles succeeded when it should have failed');
+
+ // run with invalid command
+ assert.neq(runMongoProgram.apply(this, ['mongofiles',
+ '--port', conn.port,
+ 'invalid', filesToInsert[0]]
+ .concat(passthrough.args)),
+ 0, 'invalid-command: mongofiles succeeded when it should have failed');
+
+ t.stop();
+ };
+
+ // run with plain and auth passthroughs
+ passthroughs.forEach(function(passthrough) {
+ runTests(standaloneTopology, passthrough);
+ runTests(replicaSetTopology, passthrough);
+ runTests(shardedClusterTopology, passthrough);
+ });
+}());