Source

mongo-dart / tests / DbTest.dart

vadimtsushko 9f4d884 
vadimtsushko ccd8fe4 
vadimtsushko a4f4058 
vadimtsushko 2b81e76 

vadimtsushko ccd8fe4 
vadimtsushko e056253 
vadimtsushko ccd8fe4 
vadimtsushko e056253 
vadimtsushko ccd8fe4 
vadimtsushko e056253 
vadimtsushko ccd8fe4 

vadimtsushko a4f4058 
vadimtsushko e056253 
vadimtsushko b049363 
vadimtsushko 51713e5 
vadimtsushko b049363 




vadimtsushko a4f4058 

vadimtsushko e056253 
vadimtsushko a4f4058 


vadimtsushko e056253 
vadimtsushko 51713e5 
vadimtsushko b049363 





vadimtsushko a4f4058 


vadimtsushko e056253 

vadimtsushko a4f4058 

vadimtsushko e056253 
vadimtsushko a4f4058 


vadimtsushko e056253 

vadimtsushko b049363 


vadimtsushko e056253 



vadimtsushko 17f6764 






















vadimtsushko ccd8fe4 
vadimtsushko e056253 

vadimtsushko 9f4d884 
vadimtsushko e056253 

vadimtsushko 17f6764 

vadimtsushko 9f4d884 

vadimtsushko ccd8fe4 
#library("dbtest");
#import("../lib/mongo.dart");
#import('dart:builtin');
#import('../third_party/unittest/unittest.dart');
//#import('package:unittest/unittest.dart');
testDatabaseName(){
  Db db = new Db('mongo-dart-test');
  String dbName;
  dbName = 'mongo-dart-test';
  db.validateDatabaseName(dbName);
  dbName = 'mongo-dart-test';
  db.validateDatabaseName(dbName);  
}
testCollectionInfoCursor(){
  Db db = new Db('mongo-dart-test');
  db.open().chain((c){
    DbCollection newColl = db.collection("new_collecion");
    newColl.drop();
    newColl.insertAll([{"a":1}]);
    bool found = false;
    return db.collectionsInfoCursor("new_collecion").toList();
  }).then((v){
    Expect.isTrue(v.length == 1);
    db.close();
    callbackDone();
  });
}
testRemove(){
  Db db = new Db('mongo-dart-test');
  DbCollection newColl;
  db.open().chain((c){  
    db.removeFromCollection("new_collecion_to_remove");
    newColl = db.collection("new_collecion_to_remove");  
    newColl.insertAll([{"a":1}]);
  return db.collectionsInfoCursor("new_collecion_to_remove").toList();
  }).then((v){    
    Expect.isTrue(v.length == 1);
    db.removeFromCollection("new_collecion_to_remove");
    //db.getLastError().then((v)=>print("remove result: $v"));
    newColl.find().toList().then((v1){
      Expect.isTrue(v1.isEmpty());
      newColl.drop();
      db.close();
      callbackDone();
   });
  });
}
testDropDatabase(){
  Db db = new Db('mongo-dart-test');
  db.open().chain((c){
    return db.drop();
  }).then((v){
      db.close();
      callbackDone();
  });
}
testGetNonce(){
  Db db = new Db('mongo-dart-test');
  db.open().chain((c){
    return db.getNonce();
  }).then((v){
      print(v);
      Expect.isTrue(v["ok"] == 1);
      db.close();
      callbackDone();
  }); 
}
testPwd(){
  Db db = new Db('mongo-dart-test');
  DbCollection coll;
  db.open().chain((c){
    coll = db.collection("system.users");
    return coll.find().each((user)=>print(user));
  }).then((v){
      db.close();
      callbackDone();
  }); 
}

main(){
  group("DBCommand:", (){
    asyncTest("testDropDatabase",1,testDropDatabase);
    test("testDatabaseName",testDatabaseName);
    asyncTest("testCollectionInfoCursor",1,testCollectionInfoCursor);
    asyncTest("testRemove",1,testRemove);
    asyncTest("testGetNonce",1,testGetNonce);    
    asyncTest("testPwd",1,testPwd);        
  });  
  
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.