From f20dbd1c641ae871e5abaea792a5a533d96d615b Mon Sep 17 00:00:00 2001 From: kewe63 Date: Mon, 15 Jun 2026 12:19:43 +0300 Subject: [PATCH] test(quake): cover all three CliVersionCheck variants `check_cli_version` distinguishes `SupportsCli` (parseable version >= v0.5.0, or the literal "latest") from `Assumed` (unparseable tag or missing tag) and `RequiresConfigToml` (parseable version < v0.5.0). The boolean wrapper `supports_cli_flags` only exercises the `RequiresConfigToml` boundary, so the SupportsCli-vs-Assumed distinction is documented in code but not in tests. Add a focused test that pins all three variants down with the exact tags a real operator would see ("v0.5.0", "latest", "arc_consensus:v0.6.0", "main", "abc123", None). The test fails if a future refactor collapses `Assumed` into `SupportsCli` (or vice versa), which would silently change how callers observe the tag's confidence level. --- crates/quake/src/cli_version.rs | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/crates/quake/src/cli_version.rs b/crates/quake/src/cli_version.rs index 695e97b..642639a 100644 --- a/crates/quake/src/cli_version.rs +++ b/crates/quake/src/cli_version.rs @@ -249,6 +249,56 @@ mod tests { assert!(!supports_cli_flags(Some("v0.4.0-rc1"))); } + /// `check_cli_version` exposes a three-state result. `supports_cli_flags` + /// only exercises the `RequiresConfigToml` boundary, so the distinction + /// between confirmed-`SupportsCli` and unparseable-`Assumed` is only + /// covered implicitly. This test pins the three states down so a + /// future refactor cannot quietly collapse `Assumed` into `SupportsCli` + /// (or vice versa) — they are documented as distinct so callers can + /// log or branch on unparseable tags if needed. + #[test] + fn check_cli_version_distinguishes_confirmed_from_assumed() { + // Confirmed: parseable version >= v0.5.0 -> SupportsCli. + assert_eq!( + check_cli_version(Some("v0.5.0")), + CliVersionCheck::SupportsCli + ); + assert_eq!( + check_cli_version(Some("arc_consensus:v0.6.0")), + CliVersionCheck::SupportsCli + ); + + // Confirmed: parseable version < v0.5.0 -> RequiresConfigToml. + assert_eq!( + check_cli_version(Some("v0.4.0")), + CliVersionCheck::RequiresConfigToml + ); + assert_eq!( + check_cli_version(Some("arc_consensus:v0.3.0")), + CliVersionCheck::RequiresConfigToml + ); + + // "latest" is an explicit "we know this is fine" signal, not an + // assumption. It must report SupportsCli, not Assumed. + assert_eq!( + check_cli_version(Some("latest")), + CliVersionCheck::SupportsCli + ); + assert_eq!( + check_cli_version(Some("arc_consensus:latest")), + CliVersionCheck::SupportsCli + ); + + // Unparseable tags (git SHAs, branches, "main", etc.) are + // assumptions, not confirmations. This is the only situation + // that produces Assumed besides missing tags. + assert_eq!(check_cli_version(Some("abc123")), CliVersionCheck::Assumed); + assert_eq!(check_cli_version(Some("main")), CliVersionCheck::Assumed); + + // Missing tag is the original Assumed case. + assert_eq!(check_cli_version(None), CliVersionCheck::Assumed); + } + /// Run `apply_version_compat` over `input` for the given `image_tag` and /// assert the rewritten list equals `expected`. #[track_caller]