diff --git a/Cargo.lock b/Cargo.lock index b670d370b9..fe570b6f31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7386,7 +7386,6 @@ dependencies = [ "tempfile", "termcolor", "test-case", - "tokio", "tremor-codec", "tremor-common", "tremor-influx", diff --git a/src/system.rs b/src/system.rs index d024f04b33..98b1292d6d 100644 --- a/src/system.rs +++ b/src/system.rs @@ -246,3 +246,106 @@ impl Runtime { Ok(self.kill_switch.stop(mode).await?) } } + +#[cfg(test)] +mod test { + + use super::*; + + #[test] + fn test_runtime_builder_default_exclude_with() { + let builder = Runtime::builder(); + let builder = builder.with_connector("foo"); + let builder = builder.with_debug_connectors(); + let builder = builder.with_connectors(&["bar", "baz"]); + let cfg = builder.default_exclude_connectors(); + + assert!(cfg.connectors.test("foo", PluginType::Normal)); + assert!(cfg.connectors.test("foo", PluginType::Debug)); + + assert!(cfg.connectors.test("bar", PluginType::Normal)); + assert!(cfg.connectors.test("bar", PluginType::Debug)); + + assert!(cfg.connectors.test("baz", PluginType::Normal)); + + assert!(cfg.connectors.test("boo", PluginType::Debug)); + assert!(!cfg.connectors.test("boo", PluginType::Normal)); + } + + #[test] + fn test_runtime_builder_default_include_with() { + let builder = Runtime::builder(); + let builder = builder.with_connector("foo"); + let builder = builder.without_debug_connectors(); + let builder = builder.with_connectors(&["bar", "baz"]); + let cfg = builder.default_include_connectors(); + + assert!(cfg.connectors.test("foo", PluginType::Normal)); + assert!(cfg.connectors.test("foo", PluginType::Debug)); + + assert!(cfg.connectors.test("bar", PluginType::Normal)); + assert!(!cfg.connectors.test("bar", PluginType::Debug)); + + assert!(cfg.connectors.test("baz", PluginType::Normal)); + + assert!(!cfg.connectors.test("boo", PluginType::Debug)); + assert!(cfg.connectors.test("boo", PluginType::Normal)); + } + + #[test] + fn test_runtime_builder_default_exclude_without() { + let builder = Runtime::builder(); + let builder = builder.without_connector("foo"); + let builder = builder.with_normal_connectors(); + let builder = builder.without_connectors(&["bar", "baz"]); + let cfg = builder.default_exclude_connectors(); + + assert!(!cfg.connectors.test("foo", PluginType::Normal)); + assert!(!cfg.connectors.test("foo", PluginType::Debug)); + + assert!(cfg.connectors.test("bar", PluginType::Normal)); + assert!(!cfg.connectors.test("bar", PluginType::Debug)); + + assert!(cfg.connectors.test("baz", PluginType::Normal)); + + assert!(!cfg.connectors.test("boo", PluginType::Debug)); + assert!(cfg.connectors.test("boo", PluginType::Normal)); + } + + #[test] + fn test_runtime_builder_default_include_without() { + let builder = Runtime::builder(); + let builder = builder.without_connector("foo"); + let builder = builder.without_normal_connectors(); + let builder = builder.without_connectors(&["bar", "baz"]); + let cfg = builder.default_include_connectors(); + + assert!(!cfg.connectors.test("foo", PluginType::Normal)); + assert!(!cfg.connectors.test("foo", PluginType::Debug)); + + assert!(!cfg.connectors.test("bar", PluginType::Normal)); + assert!(!cfg.connectors.test("bar", PluginType::Debug)); + + assert!(!cfg.connectors.test("baz", PluginType::Normal)); + + assert!(cfg.connectors.test("boo", PluginType::Debug)); + assert!(!cfg.connectors.test("boo", PluginType::Normal)); + } + + #[test] + fn test_runtime_config() { + let config = RuntimeConfig { + connectors: Rules::builder().default_include(), + }; + let _ = config.build(); + } + + #[tokio::test] + async fn test_runtime() -> Result<()> { + let builder = Runtime::builder(); + let config = builder.default_include_connectors(); + let (runtime, _system_h) = Runtime::start(config).await?; + runtime.stop(ShutdownMode::Graceful).await?; + Ok(()) + } +} diff --git a/tremor-connectors/src/lib.rs b/tremor-connectors/src/lib.rs index dbcf6cf7e5..3fa8d5c241 100644 --- a/tremor-connectors/src/lib.rs +++ b/tremor-connectors/src/lib.rs @@ -936,7 +936,8 @@ pub struct ConnectorType(String); impl ConnectorType { /// name of the connector - #[must_use] pub fn name(&self) -> &str { + #[must_use] + pub fn name(&self) -> &str { self.0.as_str() } } diff --git a/tremor-script/Cargo.toml b/tremor-script/Cargo.toml index 1a03b35e3c..f74a213f30 100644 --- a/tremor-script/Cargo.toml +++ b/tremor-script/Cargo.toml @@ -59,7 +59,6 @@ tremor-kv = "0.6" unicode-xid = "0.2" url = "2" xz2 = "0.1" -tokio = { version = "1", default-features = false, features = [] } [build-dependencies] lalrpop = "0.20"