diff options
author | Robert Guo <robert.guo@10gen.com> | 2016-04-22 11:50:22 -0400 |
---|---|---|
committer | Robert Guo <robert.guo@10gen.com> | 2016-04-26 12:10:05 -0400 |
commit | 992ef367f553b7b2c5f754ca7cfc3ce3769f6581 (patch) | |
tree | a0d630f9066c488f128f62955e58635386841b36 /jstests | |
parent | 2423026ef06c43d7de4fa54095702698b359a4f9 (diff) | |
download | mongo-992ef367f553b7b2c5f754ca7cfc3ce3769f6581.tar.gz |
SERVER-23789 make validate() work with MaxKey and MinKey
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthroughWithMongod/index_boundary_values_validate.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/index_boundary_values_validate.js b/jstests/noPassthroughWithMongod/index_boundary_values_validate.js new file mode 100644 index 00000000000..fd9ce6f5d21 --- /dev/null +++ b/jstests/noPassthroughWithMongod/index_boundary_values_validate.js @@ -0,0 +1,32 @@ +// Tests that the validate command works with MinKey and MaxKey. + +'use strict'; + +(function() { + var t = db.index_boundary_values_validate; + t.drop(); + + assert.writeOK(t.insert({a: MaxKey, b: MaxKey})); + assert.writeOK(t.insert({a: MaxKey, b: MinKey})); + assert.writeOK(t.insert({a: MinKey, b: MaxKey})); + assert.writeOK(t.insert({a: MinKey, b: MinKey})); + + assert.writeOK(t.insert({a: {}})); + assert.writeOK(t.insert({b: {}})); + assert.writeOK(t.insert({unindexed_field: {}})); + assert.writeOK(t.insert({a: {}, b: {}})); + + assert.commandWorked(t.createIndex({a: 1, b: 1})); + assert.commandWorked(t.createIndex({a: 1, b: -1})); + assert.commandWorked(t.createIndex({a: -1, b: 1})); + assert.commandWorked(t.createIndex({a: -1, b: -1})); + + var res = t.validate(true); + assert.commandWorked(res); + + assert.eq( + res.nrecords, 8, 'the collection had an unexpected number of records:\n' + tojson(res)); + assert.eq( + res.nIndexes, 5, 'the collection had an unexpected number of indexes:\n' + tojson(res)); + assert.eq(res.valid, true, 'the collection failed validation:\n' + tojson(res)); +})(); |