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:
58
tests/archeflow-rollback.bats
Normal file
58
tests/archeflow-rollback.bats
Normal file
@@ -0,0 +1,58 @@
|
||||
# Tests for archeflow-rollback.sh — post-merge test and phase rollback.
|
||||
#
|
||||
# Validates: argument parsing, mutual exclusivity, phase validation, test-cmd config reading.
|
||||
|
||||
setup() {
|
||||
load test_helper
|
||||
_common_setup
|
||||
}
|
||||
|
||||
teardown() {
|
||||
_common_teardown
|
||||
}
|
||||
|
||||
@test "rollback: exits with error when called with no args" {
|
||||
run "$LIB_DIR/archeflow-rollback.sh"
|
||||
[ "$status" -ne 0 ]
|
||||
}
|
||||
|
||||
@test "rollback: rejects mutually exclusive --to and --test-cmd" {
|
||||
run "$LIB_DIR/archeflow-rollback.sh" test-run --to plan --test-cmd "true"
|
||||
[ "$status" -eq 2 ]
|
||||
[[ "$output" == *"mutually exclusive"* ]]
|
||||
}
|
||||
|
||||
@test "rollback: rejects invalid phase names" {
|
||||
run "$LIB_DIR/archeflow-rollback.sh" test-run --to invalid-phase
|
||||
[ "$status" -eq 2 ]
|
||||
[[ "$output" == *"Invalid phase"* ]]
|
||||
}
|
||||
|
||||
@test "rollback: accepts valid phase names (plan, do, check)" {
|
||||
# This will fail because no git branch exists, but should NOT fail on phase validation
|
||||
run "$LIB_DIR/archeflow-rollback.sh" test-run --to plan
|
||||
# Should fail later (archeflow-git.sh rollback) not on phase validation
|
||||
[[ "$output" != *"Invalid phase"* ]]
|
||||
}
|
||||
|
||||
@test "rollback: exits 2 when no test command available" {
|
||||
run "$LIB_DIR/archeflow-rollback.sh" test-run
|
||||
[ "$status" -eq 2 ]
|
||||
[[ "$output" == *"No test command"* ]]
|
||||
}
|
||||
|
||||
@test "rollback: reads test_command from config.yaml" {
|
||||
mkdir -p .archeflow
|
||||
echo 'test_command: "echo ok"' > .archeflow/config.yaml
|
||||
# HEAD won't have archeflow in its message, but the script just warns and proceeds
|
||||
run "$LIB_DIR/archeflow-rollback.sh" test-run
|
||||
# It should pick up the command and try to run it (test should pass -> exit 0)
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"Tests passed"* ]]
|
||||
}
|
||||
|
||||
@test "rollback: rejects unknown options" {
|
||||
run "$LIB_DIR/archeflow-rollback.sh" test-run --unknown-flag
|
||||
[ "$status" -eq 2 ]
|
||||
[[ "$output" == *"Unknown option"* ]]
|
||||
}
|
||||
Reference in New Issue
Block a user