summaryrefslogtreecommitdiff
path: root/jstests/core/dbhash2.js
blob: 8e779ca7806b90535808cf20172e5af580ea3b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

mydb = db.getSisterDB("config");

t = mydb.foo;
t.drop();

t.insert({x: 1});
res1 = mydb.runCommand("dbhash");
assert(res1.fromCache.indexOf("config.foo") == -1);

res2 = mydb.runCommand("dbhash");
assert(res2.fromCache.indexOf("config.foo") >= 0);
assert.eq(res1.collections.foo, res2.collections.foo);

t.insert({x: 2});
res3 = mydb.runCommand("dbhash");
assert(res3.fromCache.indexOf("config.foo") < 0);
assert.neq(res1.collections.foo, res3.collections.foo);

// Validate dbHash with an empty database does not trigger an fassert/invariant
assert.commandFailed(db.runCommand({"dbhash": ""}));