Skip to content

Commit

Permalink
Sibling DB Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Daniels committed May 21, 2013
1 parent f7de6e5 commit 09fd7fd
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/DBCollectionTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ import cfmongodb.core.*;

deleteCol = 'deletetests';
dbDeleteCol = mongo.getDBCollection( deleteCol );

siblingCol = 'siblingtests';
dbSiblingCol = mongo.getDBCollection( siblingCol );
siblingDbSiblingCol = mongo.getDBCollection( siblingCol, "cfmongodb_tests_sibling" );

super.setUp();
}

function tearDown(){
dbAtomicCol.remove({});
dbSiblingCol.drop();
siblingDbSiblingCol.drop();
super.tearDown();
}

Expand Down Expand Up @@ -512,6 +519,27 @@ import cfmongodb.core.*;
}


/* SISTER DB TEST */
function getSiblingDB_returns_collection_from_sibling_db(){
var testdocs = [
{ "name":"test1" },
{ "name":"test2" },
{ "name":"test3" },
{ "name":"test4" }
];

// insert test docs into sibling database's collection
siblingDbSiblingCol.saveAll(testdocs);

local.thiscount = dbSiblingCol.count();
local.siblingcount = siblingdbSiblingCol.count();

assertTrue(local.thiscount eq 0, "Local sibling collection should have no docs, has #local.thiscount#.")
assertTrue(local.siblingcount eq 4, "Sibling collection should have 4 docs, has #local.siblingcount#.")
assertTrue(local.thiscount neq local.siblingcount, "Local sibling collection should have no docs, sibling should have 4.")
}


private function flush(){
//forces mongo to flush
mongo.getMongoDB().getLastError();
Expand Down

0 comments on commit 09fd7fd

Please sign in to comment.