summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/command_line_parsing.js
blob: 91aa2e5c0771a7c3449edfbe1a28810b25862856 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// validate command line parameter parsing

var baseName = "jstests_slowNightly_command_line_parsing";

// test notablescan
var m = MongoRunner.runMongod({notablescan: ""});
m.getDB( baseName ).getCollection( baseName ).save( {a:1} );
assert.throws( function() { m.getDB( baseName ).getCollection( baseName ).find( {a:1} ).toArray(); } );

// test config file 
var m2 = MongoRunner.runMongod({config: "jstests/libs/testconfig"});

var m2expected = {
    "parsed" : {
        "config" : "jstests/libs/testconfig",
        "storage" : {
            "dbPath" : m2.dbpath
        },
        "net" : {
            "port" : m2.port
        },
        "help" : false,
        "version" : false,
        "sysinfo" : false
    }
};
var m2result = m2.getDB("admin").runCommand( "getCmdLineOpts" );

// remove variables that depend on the way the test is started.
delete m2result.parsed.nopreallocj;
delete m2result.parsed.setParameter;
delete m2result.parsed.storage.engine;
delete m2result.parsed.storage.wiredTiger;
delete m2result.parsed.storage.journal;
assert.docEq( m2expected.parsed, m2result.parsed );

// test JSON config file
var m3 = MongoRunner.runMongod({config: "jstests/libs/testconfig"});

var m3expected = {
    "parsed" : {
        "config" : "jstests/libs/testconfig",
        "storage" : {
            "dbPath" : m3.dbpath
        },
        "net" : {
            "port" : m3.port
        },
        "help" : false,
        "version" : false,
        "sysinfo" : false
    }
};
var m3result = m3.getDB("admin").runCommand( "getCmdLineOpts" );

// remove variables that depend on the way the test is started.
delete m3result.parsed.nopreallocj;
delete m3result.parsed.setParameter;
delete m3result.parsed.storage.engine;
delete m3result.parsed.storage.wiredTiger;
delete m3result.parsed.storage.journal;
assert.docEq( m3expected.parsed, m3result.parsed );