From 6dedb2fbabb3b5edf581114bee50baa86694cb4e Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 30 Mar 2026 09:06:33 -0400 Subject: [PATCH] Convert 6 more predicate assertions to fabro_snapshot Replace predicates::str::contains checks with full snapshots in single-command tests: repo deinit failure, repo init help, secret get/rm missing key, exec missing API key, config show missing workflow. The remaining predicate usages are in multi-step CRUD tests and legacy config tests where programmatic assertions are still the better fit. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/crates/fabro-cli/tests/it/cmd/config.rs | 17 ++++---- lib/crates/fabro-cli/tests/it/cmd/exec.rs | 11 ++++-- lib/crates/fabro-cli/tests/it/cmd/repo.rs | 43 ++++++++++++++------- lib/crates/fabro-cli/tests/it/cmd/secret.rs | 32 ++++++++------- 4 files changed, 64 insertions(+), 39 deletions(-) diff --git a/lib/crates/fabro-cli/tests/it/cmd/config.rs b/lib/crates/fabro-cli/tests/it/cmd/config.rs index 293fa58bc..182f74471 100644 --- a/lib/crates/fabro-cli/tests/it/cmd/config.rs +++ b/lib/crates/fabro-cli/tests/it/cmd/config.rs @@ -505,13 +505,16 @@ fn config_show_missing_run_config_errors() { let context = test_context!(); let project = setup_config_show_fixture(&context); - context - .command() - .current_dir(project.path()) - .args(["config", "show", "missing.toml"]) - .assert() - .failure() - .stderr(predicate::str::contains("Workflow not found")); + let mut cmd = context.command(); + cmd.current_dir(project.path()); + cmd.args(["config", "show", "missing.toml"]); + fabro_snapshot!(context.filters(), cmd, @" + success: false + exit_code: 1 + ----- stdout ----- + ----- stderr ----- + error: Workflow not found: missing.toml + "); } #[test] diff --git a/lib/crates/fabro-cli/tests/it/cmd/exec.rs b/lib/crates/fabro-cli/tests/it/cmd/exec.rs index e6ab5ae1a..ad15a2ff9 100644 --- a/lib/crates/fabro-cli/tests/it/cmd/exec.rs +++ b/lib/crates/fabro-cli/tests/it/cmd/exec.rs @@ -1,5 +1,4 @@ use fabro_test::{fabro_snapshot, test_context}; -use predicates::prelude::*; #[test] fn invalid_permissions() { @@ -43,9 +42,13 @@ fn exec_missing_api_key_exits_with_error() { cmd.env_clear(); cmd.env("HOME", &context.home_dir); cmd.current_dir(&context.temp_dir); - cmd.assert() - .failure() - .stderr(predicate::str::contains("API key not set")); + fabro_snapshot!(context.filters(), cmd, @" + success: false + exit_code: 1 + ----- stdout ----- + ----- stderr ----- + error: API key not set for provider 'anthropic' + "); } #[test] diff --git a/lib/crates/fabro-cli/tests/it/cmd/repo.rs b/lib/crates/fabro-cli/tests/it/cmd/repo.rs index f21d90718..d64bde7af 100644 --- a/lib/crates/fabro-cli/tests/it/cmd/repo.rs +++ b/lib/crates/fabro-cli/tests/it/cmd/repo.rs @@ -1,5 +1,4 @@ use fabro_test::{fabro_snapshot, test_context}; -use predicates; fn init_git_repo(path: &std::path::Path) { std::process::Command::new("git") @@ -76,13 +75,16 @@ fn test_repo_deinit_fails_when_not_initialized() { let context = test_context!(); init_git_repo(&context.temp_dir); - context - .repo() - .arg("deinit") - .current_dir(&context.temp_dir) - .assert() - .failure() - .stderr(predicates::str::contains("not initialized")); + let mut cmd = context.repo(); + cmd.arg("deinit"); + cmd.current_dir(&context.temp_dir); + fabro_snapshot!(context.filters(), cmd, @" + success: false + exit_code: 1 + ----- stdout ----- + ----- stderr ----- + error: not initialized — fabro.toml not found + "); } #[test] @@ -111,10 +113,23 @@ fn test_repo_init_skill_installs_skill_files() { #[test] fn test_repo_init_help_does_not_show_skill() { let context = test_context!(); - let out = context.repo().args(["init", "--help"]).assert().success(); - let stdout = String::from_utf8(out.get_output().stdout.clone()).unwrap(); - assert!( - !stdout.contains("--skill"), - "--skill should be hidden from help" - ); + let mut cmd = context.repo(); + cmd.args(["init", "--help"]); + fabro_snapshot!(context.filters(), cmd, @" + success: true + exit_code: 0 + ----- stdout ----- + Initialize a new project + + Usage: fabro repo init [OPTIONS] + + Options: + --debug Enable DEBUG-level logging (default is INFO) [env: FABRO_DEBUG=] + --no-upgrade-check Disable automatic upgrade check [env: FABRO_NO_UPGRADE_CHECK=true] + --quiet Suppress non-essential output [env: FABRO_QUIET=] + --verbose Enable verbose output [env: FABRO_VERBOSE=] + --storage-dir Storage directory (default: ~/.fabro) [env: FABRO_STORAGE_DIR=[STORAGE_DIR]] + -h, --help Print help + ----- stderr ----- + "); } diff --git a/lib/crates/fabro-cli/tests/it/cmd/secret.rs b/lib/crates/fabro-cli/tests/it/cmd/secret.rs index add564f2d..b0522c094 100644 --- a/lib/crates/fabro-cli/tests/it/cmd/secret.rs +++ b/lib/crates/fabro-cli/tests/it/cmd/secret.rs @@ -104,25 +104,29 @@ fn test_secret_list_alias_ls() { #[test] fn test_secret_get_missing_key() { let context = test_context!(); - - context - .secret() - .args(["get", "NOPE"]) - .assert() - .failure() - .stderr(predicates::str::contains("secret not found")); + let mut cmd = context.secret(); + cmd.args(["get", "NOPE"]); + fabro_snapshot!(context.filters(), cmd, @" + success: false + exit_code: 1 + ----- stdout ----- + ----- stderr ----- + error: secret not found: NOPE + "); } #[test] fn test_secret_rm_missing_key() { let context = test_context!(); - - context - .secret() - .args(["rm", "NOPE"]) - .assert() - .failure() - .stderr(predicates::str::contains("secret not found")); + let mut cmd = context.secret(); + cmd.args(["rm", "NOPE"]); + fabro_snapshot!(context.filters(), cmd, @" + success: false + exit_code: 1 + ----- stdout ----- + ----- stderr ----- + error: secret not found: NOPE + "); } #[test]