Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <[email protected]>
  • Loading branch information
Licenser committed Jun 11, 2024
1 parent baad318 commit ca1d17b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 3 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 103 additions & 0 deletions src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
3 changes: 2 additions & 1 deletion tremor-connectors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
1 change: 0 additions & 1 deletion tremor-script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ca1d17b

Please sign in to comment.