aboutsummaryrefslogtreecommitdiff
path: root/.ai/scripts/tests/session-context-path.bats
blob: ea8937d867b411c1a754229f5093fad8921e9755 (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
#!/usr/bin/env bats
# Tests for the session-context-path helper: resolve the active session-context
# path from AI_AGENT_ID, defaulting to the legacy singleton.

setup() {
    SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
    SCP="$SCRIPT_DIR/session-context-path"
}

@test "session-context-path: no AI_AGENT_ID gives the legacy singleton" {
    run env -u AI_AGENT_ID "$SCP"
    [ "$status" -eq 0 ]
    [ "$output" = ".ai/session-context.org" ]
}

@test "session-context-path: empty AI_AGENT_ID gives the legacy singleton" {
    AI_AGENT_ID="" run "$SCP"
    [ "$status" -eq 0 ]
    [ "$output" = ".ai/session-context.org" ]
}

@test "session-context-path: a set AI_AGENT_ID gives a per-agent file" {
    AI_AGENT_ID="pearl.org-drill.claude.a83f" run "$SCP"
    [ "$status" -eq 0 ]
    [ "$output" = ".ai/session-context.d/pearl.org-drill.claude.a83f.org" ]
}

@test "session-context-path: two distinct ids resolve to distinct files" {
    a=$(AI_AGENT_ID="claude" "$SCP")
    b=$(AI_AGENT_ID="local-qwen" "$SCP")
    [ "$a" = ".ai/session-context.d/claude.org" ]
    [ "$b" = ".ai/session-context.d/local-qwen.org" ]
    [ "$a" != "$b" ]
}

@test "session-context-path: unsafe id characters are sanitized" {
    AI_AGENT_ID="a b/c" run "$SCP"
    [ "$status" -eq 0 ]
    [ "$output" = ".ai/session-context.d/a_b_c.org" ]
}