0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00

SERVER-19904 Test more bad inputs with filemd5

This commit is contained in:
Charlie Swanson 2018-04-30 21:48:18 -04:00
parent 43c8dcee98
commit 23533e463e

View File

@ -1,3 +1,4 @@
// Tests the basics of the filemd5 command.
// @tags: [
// # Cannot implicitly shard accessed collections because of following error: GridFS fs.chunks
// # collection must be sharded on either {files_id:1} or {files_id:1, n:1}
@ -7,12 +8,21 @@
// incompatible_with_embedded,
// ]
db.fs.chunks.drop();
db.fs.chunks.insert({files_id: 1, n: 0, data: new BinData(0, "test")});
(function() {
"use strict";
x = db.runCommand({"filemd5": 1, "root": "fs"});
assert(!x.ok, tojson(x));
db.fs.chunks.drop();
assert.writeOK(db.fs.chunks.insert({files_id: 1, n: 0, data: new BinData(0, "test")}));
db.fs.chunks.ensureIndex({files_id: 1, n: 1});
x = db.runCommand({"filemd5": 1, "root": "fs"});
assert(x.ok, tojson(x));
assert.commandFailedWithCode(db.runCommand({filemd5: 1, root: "fs"}), ErrorCodes.BadValue);
db.fs.chunks.ensureIndex({files_id: 1, n: 1});
assert.commandWorked(db.runCommand({filemd5: 1, root: "fs"}));
assert.commandFailedWithCode(db.runCommand({filemd5: 1, root: "fs", partialOk: 1, md5state: 5}),
50847);
assert.writeOK(db.fs.chunks.insert({files_id: 2, n: 0}));
assert.commandFailedWithCode(db.runCommand({filemd5: 2, root: "fs"}), 50848);
assert.writeOK(db.fs.chunks.update({files_id: 2, n: 0}, {$set: {data: 5}}));
assert.commandFailedWithCode(db.runCommand({filemd5: 2, root: "fs"}), 50849);
}());