From b34839902832bfa6f6426b3d8ff0b3b57ca4247c Mon Sep 17 00:00:00 2001 From: Brooks Townsend Date: Thu, 11 May 2023 11:42:17 -0400 Subject: [PATCH] fixed ci, ensured wadm doesn't connect to default nats Signed-off-by: Brooks Townsend see why fail Signed-off-by: Brooks Townsend who made different operating systems anyways Signed-off-by: Brooks Townsend actually handled different OS errors Signed-off-by: Brooks Townsend --- Makefile | 1 + crates/wash-lib/src/start/wadm.rs | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a2f507dc..012af851 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,7 @@ test: ## Run unit test suite test-wash-ci: @$(CARGO) nextest run --profile ci --workspace --bin wash + @$(CARGO) nextest run --profile ci -p wash-lib test-watch: ## Run unit tests continously, can optionally specify a target test filter. @$(CARGO) watch -- $(CARGO) nextest run $(TARGET) diff --git a/crates/wash-lib/src/start/wadm.rs b/crates/wash-lib/src/start/wadm.rs index caa81df0..1095673d 100644 --- a/crates/wash-lib/src/start/wadm.rs +++ b/crates/wash-lib/src/start/wadm.rs @@ -222,16 +222,29 @@ mod test { let log_path = install_dir.join("wadm.log"); let log_file = tokio::fs::File::create(&log_path).await?.into_std().await; - let child_res = start_wadm(&install_dir.join(WADM_BINARY), log_file, None).await; + let config = WadmConfig { + structured_logging: false, + js_domain: None, + nats_server_url: "nats://127.0.0.1:54321".to_string(), + nats_credsfile: None, + }; + + let child_res = start_wadm(&install_dir.join(WADM_BINARY), log_file, Some(config)).await; assert!(child_res.is_ok()); // Wait for process to exit since NATS couldn't connect assert!(child_res.unwrap().wait().await.is_ok()); let log_contents = tokio::fs::read_to_string(&log_path).await?; // wadm couldn't connect to NATS but that's okay + + // Different OS-es have different error codes, but all I care about is that wadm executed at all + #[cfg(target_os = "macos")] assert!(log_contents.contains("Connection refused (os error 61)")); + #[cfg(target_os = "linux")] + assert!(log_contents.contains("Connection refused (os error 111)")); + #[cfg(target_os = "windows")] + assert!(log_contents.contains("No connection could be made because the target machine actively refused it. (os error 10061)")); - // child_res.unwrap().kill().await?; let _ = remove_dir_all(install_dir).await; Ok(()) }