Crates.io | statsd-mock |
lib.rs | statsd-mock |
version | 0.1.1 |
source | src |
created_at | 2022-07-05 17:01:07.38072 |
updated_at | 2022-07-05 17:26:32.27562 |
description | Mocking for statsd |
homepage | |
repository | |
max_upload_size | |
id | 619830 |
size | 17,081 |
Mock for statsd crate.
Add the statsd-mock
package as a dev dependency in your Cargo.toml
file
[dev-dependencies]
statsd-mock = "0.1"
use statsd::client::Client;
fn main() {
// Start the mock server
let mock = statsd_mock::start();
// mock.addr() to get mock server address
let client = Client::new(&mock.addr(), "myapp").unwrap();
// Capturing
let response = mock.capture(|| client.incr("some.counter"));
assert_eq!(response, "myapp.some.counter:1|c");
}
MIT.