From 91253eaa291fddc7653a2487351de177241d7a54 Mon Sep 17 00:00:00 2001 From: davidko Date: Sat, 11 Jan 2025 01:42:24 +0800 Subject: [PATCH] fix(test): use correct username --- Cargo.lock | 18 ++++++++++++++++++ huber/Cargo.toml | 1 + huber/tests/config.rs | 10 +++++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 21f3445f..29bec3c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -901,6 +901,7 @@ dependencies = [ "tokio", "url", "urlencoding", + "whoami", ] [[package]] @@ -2746,6 +2747,12 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + [[package]] name = "wasm-bindgen" version = "0.2.99" @@ -2834,6 +2841,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "whoami" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" +dependencies = [ + "redox_syscall", + "wasite", + "web-sys", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/huber/Cargo.toml b/huber/Cargo.toml index aa2adfb9..d0da20ab 100644 --- a/huber/Cargo.toml +++ b/huber/Cargo.toml @@ -22,6 +22,7 @@ chrono.workspace = true assert_cmd = "2.0.16" pretty_assertions = "1.4.1" rstest = "0.24.0" +whoami = "1.5.2" [dependencies] anyhow.workspace = true diff --git a/huber/tests/config.rs b/huber/tests/config.rs index f4b00c25..98c38f40 100644 --- a/huber/tests/config.rs +++ b/huber/tests/config.rs @@ -1,5 +1,6 @@ use scopeguard::defer; use tempfile::tempdir; +use whoami::username; #[macro_use] mod common; @@ -12,11 +13,10 @@ fn test_config_not_found() { reset_huber(); } - huber_cmd!(arg("config") - .arg("show") - .assert() - .failure() - .stderr("[WARN ] Config not found: \"/home/davidko/.huber/config.yaml\"\n",)); + huber_cmd!(arg("config").arg("show").assert().failure().stderr(format!( + "[WARN ] Config not found: \"/home/{}/.huber/config.yaml\"\n", + username() + ))); } #[test]