summaryrefslogtreecommitdiff
path: root/jstests/replsets/replset6.js
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:17:50 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:18:14 -0500
commit4ae691e8edc87d0e3cfb633bb91c328426be007b (patch)
tree52079a593f54382ca13a2e741633eab1b6271893 /jstests/replsets/replset6.js
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/replsets/replset6.js')
-rw-r--r--jstests/replsets/replset6.js69
1 files changed, 39 insertions, 30 deletions
diff --git a/jstests/replsets/replset6.js b/jstests/replsets/replset6.js
index a55c44aaea7..29adfa0ae3c 100644
--- a/jstests/replsets/replset6.js
+++ b/jstests/replsets/replset6.js
@@ -3,7 +3,7 @@
baseName = "jstests_replsets_replset6";
-var rt = new ReplSetTest({ name : "replset6tests" , nodes: 2 });
+var rt = new ReplSetTest({name: "replset6tests", nodes: 2});
var nodes = rt.startSet();
rt.initiate();
var m = rt.getPrimary();
@@ -11,42 +11,51 @@ rt.awaitSecondaryNodes();
var slaves = rt.liveNodes.slaves;
s = slaves[0];
s.setSlaveOk();
-admin = m.getDB( "admin" );
+admin = m.getDB("admin");
-debug = function( foo ) {}; // print( foo ); }
+debug = function(foo) {}; // print( foo ); }
// rename within db
-m.getDB( baseName ).one.save( { a: 1 } );
-assert.soon( function() { v = s.getDB( baseName ).one.findOne(); return v && 1 == v.a; } );
-
-assert.commandWorked( admin.runCommand( {renameCollection:"jstests_replsets_replset6.one", to:"jstests_replsets_replset6.two"} ) );
-assert.soon( function() {
- if ( -1 == s.getDB( baseName ).getCollectionNames().indexOf( "two" ) ) {
- debug( "no two coll" );
- debug( tojson( s.getDB( baseName ).getCollectionNames() ) );
- return false;
- }
- if ( !s.getDB( baseName ).two.findOne() ) {
- debug( "no two object" );
- return false;
- }
- return 1 == s.getDB( baseName ).two.findOne().a; });
-assert.eq( -1, s.getDB( baseName ).getCollectionNames().indexOf( "one" ) );
+m.getDB(baseName).one.save({a: 1});
+assert.soon(function() {
+ v = s.getDB(baseName).one.findOne();
+ return v && 1 == v.a;
+});
+
+assert.commandWorked(admin.runCommand(
+ {renameCollection: "jstests_replsets_replset6.one", to: "jstests_replsets_replset6.two"}));
+assert.soon(function() {
+ if (-1 == s.getDB(baseName).getCollectionNames().indexOf("two")) {
+ debug("no two coll");
+ debug(tojson(s.getDB(baseName).getCollectionNames()));
+ return false;
+ }
+ if (!s.getDB(baseName).two.findOne()) {
+ debug("no two object");
+ return false;
+ }
+ return 1 == s.getDB(baseName).two.findOne().a;
+});
+assert.eq(-1, s.getDB(baseName).getCollectionNames().indexOf("one"));
// rename to new db
first = baseName + "_first";
second = baseName + "_second";
-m.getDB( first ).one.save( { a: 1 } );
-assert.soon( function() { return s.getDB( first ).one.findOne() && 1 == s.getDB( first ).one.findOne().a; } );
-
-assert.commandWorked( admin.runCommand( {renameCollection:"jstests_replsets_replset6_first.one", to:"jstests_replsets_replset6_second.two"} ) );
-assert.soon( function() {
- return -1 != s.getDBNames().indexOf( second ) &&
- -1 != s.getDB( second ).getCollectionNames().indexOf( "two" ) &&
- s.getDB( second ).two.findOne() &&
- 1 == s.getDB( second ).two.findOne().a; } );
-assert.eq( -1, s.getDB( first ).getCollectionNames().indexOf( "one" ) );
-
+m.getDB(first).one.save({a: 1});
+assert.soon(function() {
+ return s.getDB(first).one.findOne() && 1 == s.getDB(first).one.findOne().a;
+});
+
+assert.commandWorked(admin.runCommand({
+ renameCollection: "jstests_replsets_replset6_first.one",
+ to: "jstests_replsets_replset6_second.two"
+}));
+assert.soon(function() {
+ return -1 != s.getDBNames().indexOf(second) &&
+ -1 != s.getDB(second).getCollectionNames().indexOf("two") &&
+ s.getDB(second).two.findOne() && 1 == s.getDB(second).two.findOne().a;
+});
+assert.eq(-1, s.getDB(first).getCollectionNames().indexOf("one"));