Temporary CockroachDB databases for unit testing.
Add the following to your Cargo.toml
:
toml
[dev-dependencies]
tempdb_cockroach = ""
Install libpq-dev
(required by the postgres
crate):
sh
sudo apt install libpq-dev
Install cockroach if you haven't already:
sh
wget -qO- https://binaries.cockroachdb.com/cockroach-latest.linux-amd64.tgz | tar -xvz
sudo cp cockroach-*.linux-amd64/cockroach /usr/local/bin
```rust extern crate tempdb_cockroach;
use tempdb_cockroach::TempCockroach;
fn test() { let db = TempCockroach::new().expect("Failed to create DB"); println!("Connection string: {}", db.url());
// Cockroach process and data are cleaned up when db goes out of scope.
} ```