0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/jstests/tool/exportimport4.js
David Golden c652c07f6c
Import tools: f6fdd97dbea59639732068720558c83b88947e15 from branch v4.1
ref: 4eba41d830..f6fdd97dbe
for: 4.3.1

TOOLS-2174    mongodump and mongoexport fail to dump autoIndexId false capped collection due to invalid hint
TOOLS-2276    dump/export/files query should use extJSON v2 and ordered BSON
TOOLS-2302    Update supported build platforms to match server 4.2
TOOLS-2332    oplog_replay_local_rs.js fails on server latest
2019-07-16 11:07:21 -04:00

64 lines
1.7 KiB
JavaScript

// exportimport4.js
t = new ToolTest("exportimport4");
c = t.startDB("foo");
install_test_data = function() {
c.drop();
assert.eq(0, c.count(), "setup1");
c.save({a: [1, 2, 3, NaN, 4, null, 5]});
c.save({a: [1, 2, 3, 4, 5]});
c.save({a: [NaN]});
c.save({a: [1, 2, 3, 4, NaN, NaN, 5, NaN]});
c.save({a: [1, 2, 3, 4, null, null, 5, null]});
assert.eq(5, c.count(), "setup2");
};
// attempt to export fields without NaN
install_test_data();
var queryJSON = '{"a":{"$nin":[{"$numberDouble":"NaN"}]}}';
if (_isWindows()) {
queryJSON = '"' + queryJSON.replace(/"/g, '\\"') + '"';
}
t.runTool("export", "--out", t.extFile, "-d", t.baseName, "-c", "foo", "-q", queryJSON);
c.drop();
assert.eq(0, c.count(), "after drop", "-d", t.baseName, "-c", "foo");
t.runTool("import", "--file", t.extFile, "-d", t.baseName, "-c", "foo", "--drop");
assert.eq(2, c.count(), "after restore 1");
// attempt to export fields with NaN
install_test_data();
queryJSON = '{"a":{"$numberDouble":"NaN"}}';
if (_isWindows()) {
queryJSON = '"' + queryJSON.replace(/"/g, '\\"') + '"';
}
t.runTool("export", "--out", t.extFile, "-d", t.baseName, "-c", "foo", "-q", queryJSON);
c.drop();
assert.eq(0, c.count(), "after drop", "-d", t.baseName, "-c", "foo");
t.runTool("import", "--file", t.extFile, "-d", t.baseName, "-c", "foo", "--drop");
assert.eq(3, c.count(), "after restore 2");
// attempt to export everything
install_test_data();
t.runTool("export", "--out", t.extFile, "-d", t.baseName, "-c", "foo");
c.drop();
assert.eq(0, c.count(), "after drop", "-d", t.baseName, "-c", "foo");
t.runTool("import", "--file", t.extFile, "-d", t.baseName, "-c", "foo", "--drop");
assert.eq(5, c.count(), "after restore 3");
t.stop();