Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

test(snapshots): redact injected latest-version env so config-show snapshots don't churn (#2687)

Maximilian Roos0309fca3e0f2
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 183bbe54d..052df60cc 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -553,6 +553,23 @@ pub fn add_standard_env_redactions(settings: &mut insta::Settings) {
settings.add_redaction(".env.MOCK_CONFIG_DIR", "[MOCK_CONFIG_DIR]");
// OpenCode config directory (platform-independent override for tests)
settings.add_redaction(".env.OPENCODE_CONFIG_DIR", "[TEST_OPENCODE_CONFIG]");
+ // `wt config show --full` tests inject WORKTRUNK_TEST_LATEST_VERSION = the
+ // current crate version (so the version-check line reads "Up to date"), which
+ // would otherwise churn this `info` block on every release bump. Redact any
+ // semver-shaped value to [VERSION]; the "error" sentinel test passes a
+ // non-semver value and is left intact.
+ settings.add_dynamic_redaction(".env.WORKTRUNK_TEST_LATEST_VERSION", |value, _path| {
+ let is_semver = value.as_str().is_some_and(|s| {
+ let mut parts = s.split('.');
+ (0..3).all(|_| parts.next().is_some_and(|p| p.parse::<u32>().is_ok()))
+ && parts.next().is_none()
+ });
+ if is_semver {
+ insta::internals::Content::from("[VERSION]")
+ } else {
+ value
+ }
+ });
}
fn canonical_home_dir() -> Option<PathBuf> {
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
index b0463171f..4402dcf5e 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
@@ -41,7 +41,7 @@ info:
WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
WORKTRUNK_TEST_EPOCH: "1735776000"
WORKTRUNK_TEST_FISH_INSTALLED: "0"
- WORKTRUNK_TEST_LATEST_VERSION: 0.48.0
+ WORKTRUNK_TEST_LATEST_VERSION: "[VERSION]"
WORKTRUNK_TEST_NUSHELL_ENV: "0"
WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
index e3966e318..88a582e41 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
@@ -41,7 +41,7 @@ info:
WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
WORKTRUNK_TEST_EPOCH: "1735776000"
WORKTRUNK_TEST_FISH_INSTALLED: "0"
- WORKTRUNK_TEST_LATEST_VERSION: 0.48.0
+ WORKTRUNK_TEST_LATEST_VERSION: "[VERSION]"
WORKTRUNK_TEST_NUSHELL_ENV: "0"
WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_update_available.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_update_available.snap
index c076334c6..0794dbf7b 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_update_available.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_update_available.snap
@@ -41,7 +41,7 @@ info:
WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
WORKTRUNK_TEST_EPOCH: "1735776000"
WORKTRUNK_TEST_FISH_INSTALLED: "0"
- WORKTRUNK_TEST_LATEST_VERSION: 99.0.0
+ WORKTRUNK_TEST_LATEST_VERSION: "[VERSION]"
WORKTRUNK_TEST_NUSHELL_ENV: "0"
WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
WORKTRUNK_TEST_POWERSHELL_ENV: "0"