temp-mongo
Easy temporary MongoDB instance for unit tests.
Use the [TempMongo
] struct to get a [mongodb::Client
] that is connected to a temporary MongoDB instance.
All state of the spawned MongoDB instance is stored in a temporary directory, which will be cleaned up automatically (unless disabled).
On Unix platforms, the client is connected over a Unix socket. Windows support is planned by picking a free TCP port on the loopback adapter.
Example
See the example in the repository for a more detailed example using assert2
.
use TempMongo;
use doc;
let mongo = new.await?;
println!;
let client = mongo.client;
let collection = client.database.collection;
collection.insert_one.await?;
collection.insert_one.await?;