1 // Configuration for integration tests. This crate is about interacting with real serial ports and 2 // so some tests need actual hardware. 3 4 use envconfig::Envconfig; 5 use rstest::fixture; 6 7 // Configuration for tests requiring acutual hardware. 8 // 9 // For conveniently pulling this configuration into a test case as a parameter, you might want to 10 // use the test fixture [`hw_config`]. 11 #[derive(Clone, Debug, Envconfig, Eq, PartialEq)] 12 pub struct HardwareConfig { 13 #[envconfig(from = "SERIALPORT_TEST_PORT_1")] 14 pub port_1: String, 15 #[envconfig(from = "SERIALPORT_TEST_PORT_2")] 16 pub port_2: String, 17 } 18 19 // Test fixture for conveniently pulling the actual hardware configuration into test cases. 20 // 21 // See [`fixture`](rstest::fixture) for details. 22 #[fixture] hw_config() -> HardwareConfig23pub fn hw_config() -> HardwareConfig { 24 HardwareConfig::init_from_env().unwrap() 25 } 26