-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move the Drop a collection test to the tests folder
- Loading branch information
Showing
4 changed files
with
47 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "tests", | ||
"description": "High level MongoDB collection tests for vibe.d", | ||
"dependencies": { | ||
"vibe-d:mongodb": {"path": "../../../"} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/// Requires mongo service running on localhost with default port | ||
/// Uses test database | ||
|
||
module app; | ||
|
||
import vibe.core.core; | ||
import vibe.core.log; | ||
import vibe.data.bson; | ||
import vibe.db.mongo.mongo; | ||
|
||
import std.algorithm : all, canFind, equal, map, sort; | ||
import std.conv : to; | ||
import std.encoding : sanitize; | ||
import std.exception : assertThrown; | ||
|
||
|
||
void runTest(ushort port) | ||
{ | ||
MongoClient client = connectMongoDB("127.0.0.1", port); | ||
|
||
/// Drop a collection | ||
auto chunks = client.getCollection("test.fs.chunks"); | ||
chunks.drop; | ||
} | ||
|
||
int main(string[] args) | ||
{ | ||
int ret = 0; | ||
ushort port = args.length > 1 | ||
? args[1].to!ushort | ||
: MongoClientSettings.defaultPort; | ||
runTask(() nothrow { | ||
try runTest(port); | ||
catch (Exception e) assert(false, e.toString()); | ||
finally exitEventLoop(true); | ||
}); | ||
runEventLoop(); | ||
return ret; | ||
} |