aboutsummaryrefslogtreecommitdiff
path: root/.ai/scripts/tests/inbox-status.bats
blob: bc8a734ca56d15e694de373a796f034ad80ef632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bats
# Tests for inbox-status: list unprocessed inbox handoffs, exit nonzero if any.

setup() {
    SCRIPT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)/inbox-status"
    TMP="$(mktemp -d)"
}

teardown() {
    rm -rf "$TMP"
}

@test "inbox-status: no inbox/ dir exits 2" {
    cd "$TMP"
    run "$SCRIPT"
    [ "$status" -eq 2 ]
}

@test "inbox-status: only .gitkeep is clean (exit 0)" {
    mkdir "$TMP/inbox"
    touch "$TMP/inbox/.gitkeep"
    cd "$TMP"
    run "$SCRIPT"
    [ "$status" -eq 0 ]
    [[ "$output" == *"0 pending"* ]]
}

@test "inbox-status: a handoff is pending (exit 1, listed)" {
    mkdir "$TMP/inbox"
    touch "$TMP/inbox/.gitkeep"
    echo body > "$TMP/inbox/2026-05-31-from-work-thing.org"
    cd "$TMP"
    run "$SCRIPT"
    [ "$status" -eq 1 ]
    [[ "$output" == *"1 pending"* ]]
    [[ "$output" == *"2026-05-31-from-work-thing.org"* ]]
}

@test "inbox-status: excludes lint-followups.org and PROCESSED-* artifacts" {
    mkdir "$TMP/inbox"
    touch "$TMP/inbox/.gitkeep" "$TMP/inbox/lint-followups.org" "$TMP/inbox/PROCESSED-old.org"
    cd "$TMP"
    run "$SCRIPT"
    [ "$status" -eq 0 ]
    [[ "$output" == *"0 pending"* ]]
}

@test "inbox-status: -q suppresses the per-item lines" {
    mkdir "$TMP/inbox"
    echo body > "$TMP/inbox/handoff.org"
    cd "$TMP"
    run "$SCRIPT" -q
    [ "$status" -eq 1 ]
    [[ "$output" == *"1 pending"* ]]
    [[ "$output" != *"  handoff.org"* ]]
}