test: add bats test suite for lib/ helper scripts
110 tests across 10 test files covering all lib/ scripts: - archeflow-event.sh: JSONL format, seq numbering, parent fields, validation - archeflow-memory.sh: add/list/decay/forget/inject/extract commands - archeflow-git.sh: branch creation, commit format, merge strategies, safety - archeflow-report.sh: markdown output, summary mode, in-progress handling - archeflow-progress.sh: progress.md generation, JSON mode, error handling - archeflow-score.sh: archetype scoring, effectiveness report, validation - archeflow-dag.sh: DAG rendering, color flags, tree structure - archeflow-rollback.sh: arg parsing, phase validation, mutual exclusivity - archeflow-init.sh: template listing, clone from project, arg validation - archeflow-review.sh: diff modes, stats, branch/commit range review Includes test_helper.bash (shared setup/teardown with temp git repos) and scripts/run-tests.sh runner.
This commit is contained in:
78
tests/archeflow-progress.bats
Normal file
78
tests/archeflow-progress.bats
Normal file
@@ -0,0 +1,78 @@
|
||||
# Tests for archeflow-progress.sh — live progress file generation.
|
||||
#
|
||||
# Validates: markdown output structure, JSON mode, missing events handling, exit codes.
|
||||
|
||||
setup() {
|
||||
load test_helper
|
||||
_common_setup
|
||||
|
||||
# Create standard events for progress tests
|
||||
mkdir -p .archeflow/events
|
||||
cat > ".archeflow/events/test-run.jsonl" <<'EVENTS'
|
||||
{"ts":"2026-04-03T10:00:00Z","run_id":"test-run","seq":1,"parent":[],"type":"run.start","phase":"plan","agent":null,"data":{"task":"Build feature","workflow":"standard","team":"default"}}
|
||||
{"ts":"2026-04-03T10:01:00Z","run_id":"test-run","seq":2,"parent":[1],"type":"agent.complete","phase":"plan","agent":"creator","data":{"archetype":"creator","duration_ms":60000,"tokens":1500,"estimated_cost_usd":0.02,"summary":"Planned"}}
|
||||
EVENTS
|
||||
}
|
||||
|
||||
@test "progress: exits 1 with usage when called with no args" {
|
||||
run "$LIB_DIR/archeflow-progress.sh"
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"Usage"* ]]
|
||||
}
|
||||
|
||||
@test "progress: exits 1 when events file not found" {
|
||||
run "$LIB_DIR/archeflow-progress.sh" nonexistent-run
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"not found"* ]]
|
||||
}
|
||||
|
||||
@test "progress: default mode generates progress.md" {
|
||||
run "$LIB_DIR/archeflow-progress.sh" test-run
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f ".archeflow/progress.md" ]
|
||||
[[ "$output" == *"# ArcheFlow Run: test-run"* ]]
|
||||
[[ "$output" == *"Status:"* ]]
|
||||
[[ "$output" == *"Progress"* ]]
|
||||
}
|
||||
|
||||
@test "progress: json mode outputs valid JSON" {
|
||||
run "$LIB_DIR/archeflow-progress.sh" test-run --json
|
||||
[ "$status" -eq 0 ]
|
||||
echo "$output" | jq empty
|
||||
local run_id
|
||||
run_id=$(echo "$output" | jq -r '.run_id')
|
||||
[ "$run_id" = "test-run" ]
|
||||
}
|
||||
|
||||
@test "progress: json mode includes completed agents" {
|
||||
run "$LIB_DIR/archeflow-progress.sh" test-run --json
|
||||
[ "$status" -eq 0 ]
|
||||
local completed_count
|
||||
completed_count=$(echo "$output" | jq '.completed | length')
|
||||
[ "$completed_count" -eq 1 ]
|
||||
local agent
|
||||
agent=$(echo "$output" | jq -r '.completed[0].agent')
|
||||
[ "$agent" = "creator" ]
|
||||
}
|
||||
|
||||
@test "progress: json mode shows correct phase" {
|
||||
run "$LIB_DIR/archeflow-progress.sh" test-run --json
|
||||
[ "$status" -eq 0 ]
|
||||
local phase
|
||||
phase=$(echo "$output" | jq -r '.phase')
|
||||
[ "$phase" = "plan" ]
|
||||
}
|
||||
|
||||
@test "progress: reports error in json when events file missing" {
|
||||
run "$LIB_DIR/archeflow-progress.sh" missing-run --json
|
||||
# JSON mode returns the JSON even on error
|
||||
local error
|
||||
error=$(echo "$output" | jq -r '.error // empty')
|
||||
[[ "$error" == *"not found"* ]]
|
||||
}
|
||||
|
||||
@test "progress: rejects unknown flags" {
|
||||
run "$LIB_DIR/archeflow-progress.sh" test-run --invalid
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"Unknown flag"* ]]
|
||||
}
|
||||
Reference in New Issue
Block a user