#mocking #statsd #client #server

statsd-mock

Mocking for statsd

2 releases

0.1.1 Jul 5, 2022
0.1.0 Jul 5, 2022

#23 in #statsd

Custom license

8KB
133 lines

Mock StatsD for Rust

Mock for statsd crate.

Crates.io MIT licensed Build Status Codecov

Website | API Docs

Usage

Add the statsd-mock package as a dev dependency in your Cargo.toml file

[dev-dependencies]
statsd-mock = "0.1"

Example

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");
}

License

MIT.

Dependencies

~425KB