summaryrefslogtreecommitdiff
path: root/jstests/rename3.js
blob: 5e1005f8176a5373619c99cb0fb3f6219db11c61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25


a = db.rename3a
b = db.rename3b

a.drop();
b.drop()

a.save( { x : 1 } );
b.save( { x : 2 } );

assert.eq( 1 , a.findOne().x , "before 1a" );
assert.eq( 2 , b.findOne().x , "before 2a" );

res = b.renameCollection( a._shortName );
assert.eq( 0 , res.ok , "should fail: " + tojson( res ) );

assert.eq( 1 , a.findOne().x , "before 1b" );
assert.eq( 2 , b.findOne().x , "before 2b" );

res = b.renameCollection( a._shortName , true )
assert.eq( 1 , res.ok , "should succeed:" + tojson( res ) );

assert.eq( 2 , a.findOne().x , "after 1" );
assert.isnull( b.findOne() , "after 2" );