1use flow_component::Value;
2use thiserror::Error;
3use wick_packet::Packet;
4
5use crate::assertion_packet::TestKind;
6use crate::operators::{ContainsError, OrderingError, RegexError};
7
8#[derive(Error, Debug, PartialEq)]
9#[non_exhaustive]
10pub enum TestError {
11 #[error("Could not read file : {0}")]
12 ReadFailed(String),
13 #[error("Could not parse contents as YAML : {0}")]
14 ParseFailed(String),
15 #[error("Invocation failed: {0}")]
16 InvocationFailed(String),
17 #[error("Invocation timed out: {0}")]
18 InvocationTimeout(String),
19 #[error("Serialization failed: {0}")]
20 Serialization(String),
21 #[error("Deserialization failed: {0}")]
22 Deserialization(String),
23 #[error("Could not render configuration: {0}")]
24 Configuration(String),
25 #[error("Could not create component instance to test: {0}")]
26 Factory(String),
27 #[error("Could not find operation {0} on this component")]
28 OpNotFound(String),
29 #[error(transparent)]
30 ConfigUnsatisfied(wick_packet::Error),
31 #[error("Test input sent packets after marking input '{0}' as done")]
32 PacketsAfterDone(String),
33 #[error("Got an output packet for a port '{0}' we've never seen")]
34 InvalidPort(String),
35 #[error("Assertion failed")]
36 Assertion(TestKind, Packet, AssertionFailure),
37 #[error("Could not get path from packet data: {0}")]
38 DotPath(String),
39}
40
41#[derive(Error, Debug, PartialEq)]
42pub enum AssertionFailure {
43 #[error("Packet does not loosley match expected data {0}")]
44 Contains(ContainsError),
45 #[error("Packet does not match expected data {0}")]
46 Ordering(OrderingError),
47 #[error("Packet does not match expected data {0}")]
48 Regex(RegexError),
49 #[error("Payload mismatch")]
50 Payload(Value, Value),
51 #[error("Expected data in packet but got none")]
52 ActualNoData,
53 #[error("Expected no data in packet but got some")]
54 ExpectedNoData,
55 #[error("Flag mismatch")]
56 Flags(u8, u8),
57 #[error("Port name mismatch")]
58 Name(String, String),
59}