mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-07 08:27:12 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
parent
9deb84cd5a
commit
6dedb2fbab
4 changed files with 64 additions and 39 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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_DIR> Storage directory (default: ~/.fabro) [env: FABRO_STORAGE_DIR=[STORAGE_DIR]]
|
||||
-h, --help Print help
|
||||
----- stderr -----
|
||||
");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue