Permalink
Browse files

Fix some js tests for parallel

  • Loading branch information...
1 parent 7b3ac96 commit ac674ac1530d7a7c58f567894135e31783deb65a @erh erh committed Dec 24, 2012
File renamed without changes.
@@ -1,6 +1,8 @@
// Ensure that inserts and updates of the system.users collection validate the schema of inserted
// documents.
+mydb = db.getSisterDB( "validate_user_documents" );
+
function assertGLEOK(status) {
assert(status.ok && status.err === null,
"Expected OK status object; found " + tojson(status));
@@ -11,38 +13,40 @@ function assertGLENotOK(status) {
"Expected not-OK status object; found " + tojson(status));
}
-db.dropDatabase();
+mydb.dropDatabase();
//
// Tests of the insert path
//
// Valid compatibility document; insert should succeed.
-db.system.users.insert({ user: "spencer", pwd: hex_md5("spencer:mongo:a"), readOnly: true });
-assertGLEOK(db.getLastErrorObj());
+mydb.system.users.insert({ user: "spencer", pwd: hex_md5("spencer:mongo:a"), readOnly: true });
+assertGLEOK(mydb.getLastErrorObj());
// Invalid compatibility document; insert should fail.
-db.system.users.insert({ user: "andy", readOnly: true });
-assertGLENotOK(db.getLastErrorObj());
+mydb.system.users.insert({ user: "andy", readOnly: true });
+assertGLENotOK(mydb.getLastErrorObj());
// Valid extended document; insert should succeed.
-db.system.users.insert({ user: "spencer", userSource: "test2", roles: ["dbAdmin"] });
-assertGLEOK(db.getLastErrorObj());
+mydb.system.users.insert({ user: "spencer", userSource: "test2", roles: ["dbAdmin"] });
+assertGLEOK(mydb.getLastErrorObj());
// Invalid extended document; insert should fail.
-db.system.users.insert({ user: "andy", userSource: "test2", roles: ["dbAdmin", 15] });
-assertGLENotOK(db.getLastErrorObj());
+mydb.system.users.insert({ user: "andy", userSource: "test2", roles: ["dbAdmin", 15] });
+assertGLENotOK(mydb.getLastErrorObj());
//
// Tests of the update path
//
// Update a document in a legal way, expect success.
-db.system.users.update({user: "spencer", userSource: null}, { $set: {readOnly: false} });
-assertGLEOK(db.getLastErrorObj());
+mydb.system.users.update({user: "spencer", userSource: null}, { $set: {readOnly: false} });
+assertGLEOK(mydb.getLastErrorObj());
// Update a document in a way that is illegal, expect failure.
-db.system.users.update({user: "spencer", userSource: null}, { $unset: {pwd: 1} });
-assertGLENotOK(db.getLastErrorObj());
+mydb.system.users.update({user: "spencer", userSource: null}, { $unset: {pwd: 1} });
+assertGLENotOK(mydb.getLastErrorObj());
+
+mydb.dropDatabase();

0 comments on commit ac674ac

Please sign in to comment.