fabro/lib/crates/fabro-cli/tests/it/cmd/wait.rs
Bryan Helmkamp 4dc31192b8 refactor(scratch): remove stale scratch file refs
Drop scratch-only compatibility paths and legacy test scaffolding now that
SlateDB-backed state is authoritative. This removes scratch file fallbacks,
updates docs and UI labels, and moves tests onto durable store-backed helpers.
2026-04-07 20:40:06 -04:00

116 lines
3.4 KiB
Rust

use fabro_test::{fabro_snapshot, test_context};
use super::support::{setup_completed_fast_dry_run, setup_created_fast_dry_run};
#[test]
fn help() {
let context = test_context!();
let mut cmd = context.command();
cmd.args(["wait", "--help"]);
fabro_snapshot!(context.filters(), cmd, @"
success: true
exit_code: 0
----- stdout -----
Block until a workflow run completes
Usage: fabro wait [OPTIONS] <RUN>
Arguments:
<RUN> Run ID prefix or workflow name (most recent run)
Options:
--json Output as JSON [env: FABRO_JSON=]
--server <SERVER> Fabro server target: http(s) URL or absolute Unix socket path [env: FABRO_SERVER=]
--debug Enable DEBUG-level logging (default is INFO) [env: FABRO_DEBUG=]
--timeout <SECONDS> Maximum time to wait in seconds
--interval <MS> Poll interval in milliseconds [default: 1000]
--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=]
-h, --help Print help
----- stderr -----
");
}
#[test]
fn wait_completed_run_prints_success_summary() {
let context = test_context!();
let run = setup_completed_fast_dry_run(&context);
let mut filters = context.filters();
filters.push((
r"\b\d+(\.\d+)?(ms|s)\b".to_string(),
"[DURATION]".to_string(),
));
let mut cmd = context.command();
cmd.args(["wait", &run.run_id]);
fabro_snapshot!(filters, cmd, @"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Succeeded [ULID] [DURATION]
");
}
#[test]
fn wait_completed_run_reads_store_without_status_or_conclusion_files() {
let context = test_context!();
let run = setup_completed_fast_dry_run(&context);
let mut filters = context.filters();
filters.push((
r"\b\d+(\.\d+)?(ms|s)\b".to_string(),
"[DURATION]".to_string(),
));
let mut cmd = context.command();
cmd.args(["wait", &run.run_id]);
fabro_snapshot!(filters, cmd, @"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Succeeded [ULID] [DURATION]
");
}
#[test]
fn wait_completed_run_json_outputs_status_and_duration() {
let context = test_context!();
let run = setup_completed_fast_dry_run(&context);
let mut filters = context.filters();
filters.push((
r#""duration_ms":\s*\d+"#.to_string(),
r#""duration_ms": [DURATION_MS]"#.to_string(),
));
let mut cmd = context.command();
cmd.args(["wait", "--json", &run.run_id]);
fabro_snapshot!(filters, cmd, @r###"
success: true
exit_code: 0
----- stdout -----
{
"run_id": "[ULID]",
"status": "succeeded",
"duration_ms": [DURATION_MS]
}
----- stderr -----
"###);
}
#[test]
fn wait_submitted_run_times_out() {
let context = test_context!();
let run = setup_created_fast_dry_run(&context);
let mut cmd = context.command();
cmd.args(["wait", "--timeout", "1", "--interval", "10", &run.run_id]);
fabro_snapshot!(context.filters(), cmd, @"
success: false
exit_code: 1
----- stdout -----
----- stderr -----
error: Timed out after 1s waiting for run '[ULID]'
");
}