1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Run tests against isolated, disposable `nats-server` instances
//!
//! Every test gets its own [`NatsServer`], bound to random ports on
//! `127.0.0.1` and backed by a private temporary directory, so tests can
//! run in parallel without sharing any state.
//!
//! ```no_run
//! use watermelon_testkit::NatsServer;
//!
//! # async fn example() {
//! let Some(server) = NatsServer::builder().jetstream().start().await else {
//! // nats-server isn't installed: skip the test
//! return;
//! };
//! println!("connect to {}", server.client_url());
//! # }
//! ```
//!
//! # Locating `nats-server`
//!
//! The binary is taken from the `NATS_SERVER_BIN` environment variable when
//! it points to an existing file, otherwise it's looked up in `PATH`.
//!
//! When no binary can be found [`NatsServerBuilder::start`] returns `None`,
//! so that the test can be skipped. If the `CI` environment variable is set
//! it panics instead, so that a misconfigured CI can't silently skip tests.
//!
//! # Debugging failures
//!
//! The server runs with trace logging enabled. When a test panics while a
//! [`NatsServer`] is alive, the tail of the server log is printed and the
//! server's temporary directory, containing the configuration and the full
//! log, is kept.
pub use ;
pub use ;