From 383a6fad1f84d58d914be970ee9feca1630b6617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Fr=C3=B6lich?= Date: Thu, 13 Jul 2023 21:03:55 +0200 Subject: [PATCH 1/2] test: more coverage --- src-tauri/tests/connectors.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src-tauri/tests/connectors.rs b/src-tauri/tests/connectors.rs index 300908e..c578e48 100644 --- a/src-tauri/tests/connectors.rs +++ b/src-tauri/tests/connectors.rs @@ -60,4 +60,18 @@ mod ghostunnel_docker_tests { } }; } + #[test] + fn test_d_check_not_running() { + let connector = get_connector_context("test", "GhostunnelDocker"); + let _res = match connector.check_running() { + Ok(container_summary) => { + println!("{:?}", container_summary); + 0 + }, + Err(why) => { + println!("{}", why); + 1 + } + }; + } } From fa449ae13691c3c8a03e5cf67ffe23c63adc9681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Fr=C3=B6lich?= Date: Thu, 13 Jul 2023 21:18:47 +0200 Subject: [PATCH 2/2] test: add connection unit tests --- src-tauri/src/connection.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src-tauri/src/connection.rs b/src-tauri/src/connection.rs index 75ce4de..3266fb9 100644 --- a/src-tauri/src/connection.rs +++ b/src-tauri/src/connection.rs @@ -85,3 +85,21 @@ pub trait Connector { fn check_running(&self) -> Result, ConnectError>; fn terminate(&self, name: &str) -> Result<(), ConnectError>; } + +#[cfg(test)] +mod connection_tests { + #[test] + fn test_get_connector_context() { + let connector = super::get_connector_context("test", "GhostunnelDocker"); + assert_eq!("test", connector.name); + let other = super::get_connector_context("other", "other"); + assert_eq!("other", other.name); + } + + #[test] + fn test_connecterror() { + let err = super::ConnectError::new("test"); + assert_eq!("test", err.details); + assert_eq!(format!("{}", err), "test"); + } +} \ No newline at end of file