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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Test harness for observing and asserting on event flow.
//!
//! Enable with the `test-harness` feature:
//!
//! ```toml
//! [dev-dependencies]
//! maiko = { version = "0.3", features = ["test-harness"] }
//! ```
//!
//! # Example
//!
//! ```ignore
//! use maiko::testing::Harness;
//!
//! // Create harness BEFORE starting supervisor
//! let mut test = Harness::new(&mut supervisor).await;
//! supervisor.start().await?;
//!
//! test.record().await;
//! let id = test.send_as(&producer, MyEvent::Data(42)).await?;
//! test.settle().await;
//!
//! // Query using spies
//! assert!(test.event(id).was_delivered_to(&consumer));
//! assert_eq!(1, test.actor(&consumer).events_received());
//!
//! // Or use EventQuery for complex queries
//! let orders = test.events()
//! .sent_by(&trader)
//! .matching_event(|e| matches!(e, MyEvent::Order(_)))
//! .count();
//!
//! // Or trace event propagation with EventChain
//! let chain = test.chain(id);
//! assert!(chain.actors().exact(&[&producer, &processor, &writer])); // exact path
//! assert!(chain.actors().segment(&[&processor, &writer])); // contiguous sub-path
//! assert!(chain.actors().passes_through(&[&producer, &writer])); // gaps allowed
//! assert!(chain.events().segment(&["Input", "Processed", "Output"]));
//! ```
//!
//! # Note
//!
//! Spy and query types use `Rc` internally and are `!Send`. This is intentional:
//! they are designed for single-threaded test contexts only.
//!
//! # Warning
//!
//! **Do not use in production.** See [`Harness`] documentation for details.
pub
pub use ActorSpy;
pub use ActorTrace;
pub use EventChain;
pub use EventCollector;
pub use EventEntry;
pub use EventMatcher;
pub use EventQuery;
pub use EventSpy;
pub use EventTrace;
pub use Expectation;
pub use Harness;
pub use TopicSpy;
pub type EventRecords<E, T> = Arc;