# Tests for archeflow-review.sh — git diff extraction for code review. # # Validates: argument parsing, diff modes, stats output, empty diff handling. setup() { load test_helper _common_setup } teardown() { _common_teardown } @test "review: --help shows usage" { run "$LIB_DIR/archeflow-review.sh" --help [ "$status" -eq 0 ] [[ "$output" == *"Usage"* ]] [[ "$output" == *"--branch"* ]] [[ "$output" == *"--commit"* ]] } @test "review: exits 1 when no changes to review" { run "$LIB_DIR/archeflow-review.sh" [ "$status" -eq 1 ] [[ "$output" == *"No changes"* ]] } @test "review: shows diff for uncommitted changes" { echo "new content" > testfile.txt git add testfile.txt run "$LIB_DIR/archeflow-review.sh" [ "$status" -eq 0 ] [[ "$output" == *"testfile.txt"* ]] } @test "review: --stat-only prints stats without diff content" { echo "stat content" > statfile.txt git add statfile.txt run "$LIB_DIR/archeflow-review.sh" --stat-only [ "$status" -eq 0 ] # stderr has stats, stdout should be empty (no diff) # But run captures both, so just check it ran ok [[ "$output" == *"Review Stats"* ]] } @test "review: --branch fails for nonexistent branch" { run "$LIB_DIR/archeflow-review.sh" --branch nonexistent-branch-xyz [ "$status" -ne 0 ] [[ "$output" == *"not found"* ]] } @test "review: rejects unknown arguments" { run "$LIB_DIR/archeflow-review.sh" --unknown [ "$status" -ne 0 ] [[ "$output" == *"Unknown argument"* ]] } @test "review: --branch shows diff against base" { # Create a feature branch with changes git checkout -b feat/test-review --quiet echo "feature" > feature.txt git add feature.txt git commit -m "feat: add feature" --quiet git checkout main --quiet run "$LIB_DIR/archeflow-review.sh" --branch feat/test-review [ "$status" -eq 0 ] [[ "$output" == *"feature.txt"* ]] } @test "review: --commit shows diff for commit range" { echo "first" > first.txt git add first.txt git commit -m "first" --quiet echo "second" > second.txt git add second.txt git commit -m "second" --quiet run "$LIB_DIR/archeflow-review.sh" --commit HEAD~1..HEAD [ "$status" -eq 0 ] [[ "$output" == *"second.txt"* ]] }