-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathintegration-test.sh
More file actions
executable file
·144 lines (100 loc) · 5.3 KB
/
Copy pathintegration-test.sh
File metadata and controls
executable file
·144 lines (100 loc) · 5.3 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env bash
# idstack integration tests — behavioral tests for bin scripts
set -e
PASS=0
FAIL=0
TOTAL=0
IDSTACK_DIR="$(cd "$(dirname "$0")/.." && pwd)"
TEST_DIR=$(mktemp -d)
trap "rm -rf $TEST_DIR" EXIT
check() {
TOTAL=$((TOTAL + 1))
if eval "$2" 2>/dev/null; then
echo " PASS: $1"
PASS=$((PASS + 1))
else
echo " FAIL: $1"
FAIL=$((FAIL + 1))
fi
}
echo "idstack integration tests"
echo " test dir: $TEST_DIR"
echo ""
cd "$TEST_DIR"
# --- idstack-timeline-log ---
echo "## idstack-timeline-log"
check "creates .idstack/ and timeline.jsonl" \
"$IDSTACK_DIR/bin/idstack-timeline-log '{\"skill\":\"test\",\"event\":\"completed\",\"score\":72}' && [ -f .idstack/timeline.jsonl ]"
check "appends valid JSON with ts field" \
"python3 -c \"import json; d=json.loads(open('.idstack/timeline.jsonl').readline()); assert 'ts' in d and d['skill']=='test'\""
check "handles empty arg without error" \
"$IDSTACK_DIR/bin/idstack-timeline-log ''"
check "handles no arg without error" \
"$IDSTACK_DIR/bin/idstack-timeline-log"
check "multiple appends create multiple lines" \
"$IDSTACK_DIR/bin/idstack-timeline-log '{\"skill\":\"second\",\"event\":\"completed\"}' && [ \$(wc -l < .idstack/timeline.jsonl | tr -d ' ') -eq 2 ]"
echo ""
# --- idstack-learnings-log ---
echo "## idstack-learnings-log"
check "creates learnings.jsonl" \
"$IDSTACK_DIR/bin/idstack-learnings-log '{\"skill\":\"import\",\"type\":\"operational\",\"key\":\"test\",\"insight\":\"test insight\",\"confidence\":8}' && [ -f .idstack/learnings.jsonl ]"
check "appends valid JSON with ts field" \
"python3 -c \"import json; d=json.loads(open('.idstack/learnings.jsonl').readline()); assert 'ts' in d and d['type']=='operational'\""
check "handles empty arg without error" \
"$IDSTACK_DIR/bin/idstack-learnings-log ''"
echo ""
# --- idstack-learnings-search ---
echo "## idstack-learnings-search"
# Add a second learning of different type
$IDSTACK_DIR/bin/idstack-learnings-log '{"skill":"review","type":"pattern","key":"test2","insight":"pattern insight","confidence":7}'
check "returns results with --limit" \
"[ \$($IDSTACK_DIR/bin/idstack-learnings-search --limit 1 | wc -l | tr -d ' ') -eq 1 ]"
check "returns all when limit exceeds count" \
"[ \$($IDSTACK_DIR/bin/idstack-learnings-search --limit 99 | wc -l | tr -d ' ') -eq 2 ]"
check "filters by --type" \
"$IDSTACK_DIR/bin/idstack-learnings-search --limit 10 --type operational | python3 -c \"import json,sys; d=json.loads(sys.stdin.readline()); assert d['type']=='operational'\""
check "no file returns empty" \
"rm -f .idstack/learnings.jsonl && [ -z \"\$($IDSTACK_DIR/bin/idstack-learnings-search --limit 3)\" ]"
echo ""
# --- idstack-status ---
echo "## idstack-status"
check "no timeline shows empty state message" \
"rm -f .idstack/timeline.jsonl && $IDSTACK_DIR/bin/idstack-status | grep -q 'No course data yet'"
# Rebuild timeline for status tests
$IDSTACK_DIR/bin/idstack-timeline-log '{"skill":"needs-analysis","event":"completed","training_justified":true}'
$IDSTACK_DIR/bin/idstack-timeline-log '{"skill":"course-quality-review","event":"completed","score":65,"dimensions":{"teaching_presence":7,"social_presence":3,"cognitive_presence":5}}'
check "shows skills completed checkboxes" \
"$IDSTACK_DIR/bin/idstack-status | grep -q '\[x\] /needs-analysis'"
check "shows quality trend" \
"$IDSTACK_DIR/bin/idstack-status | grep -q 'Quality trend: 65'"
check "suggests next skill" \
"$IDSTACK_DIR/bin/idstack-status | grep -q 'Suggested next'"
echo ""
# --- idstack-gen-skills ---
echo "## idstack-gen-skills"
check "dry-run passes when fresh" \
"$IDSTACK_DIR/bin/idstack-gen-skills --dry-run"
check "dry-run detects stale SKILL.md" \
"echo 'stale content' >> $IDSTACK_DIR/skills/needs-analysis/SKILL.md && ! $IDSTACK_DIR/bin/idstack-gen-skills --dry-run"
check "regenerate fixes staleness" \
"$IDSTACK_DIR/bin/idstack-gen-skills && $IDSTACK_DIR/bin/idstack-gen-skills --dry-run"
echo ""
# --- idstack-learnings-delete ---
echo "## idstack-learnings-delete"
check "returns error if no arguments provided" \
"! $IDSTACK_DIR/bin/idstack-learnings-delete"
check "returns error if no file exists" \
"rm -f .idstack/learnings.jsonl && ! $IDSTACK_DIR/bin/idstack-learnings-delete somekey"
# Setup data for delete tests
$IDSTACK_DIR/bin/idstack-learnings-log '{"skill":"test","type":"fact","key":"key1","insight":"one"}'
$IDSTACK_DIR/bin/idstack-learnings-log '{"skill":"test","type":"fact","key":"key2","insight":"two"}'
$IDSTACK_DIR/bin/idstack-learnings-log '{"skill":"test","type":"fact","key":"key1","insight":"three"}'
check "returns error if key not found" \
"! $IDSTACK_DIR/bin/idstack-learnings-delete missingkey"
check "deletes the most recent entry with the key when there are duplicates" \
"$IDSTACK_DIR/bin/idstack-learnings-delete key1 && python3 -c \"import json,sys; lines=[json.loads(l) for l in open('.idstack/learnings.jsonl')]; assert len(lines)==2 and lines[0]['key']=='key1' and lines[0]['insight']=='one' and lines[1]['key']=='key2'\""
check "deletes a specific learning" \
"$IDSTACK_DIR/bin/idstack-learnings-delete key2 && python3 -c \"import json,sys; lines=[json.loads(l) for l in open('.idstack/learnings.jsonl')]; assert len(lines)==1 and lines[0]['key']=='key1'\""
echo ""
echo "Results: $PASS/$TOTAL passed, $FAIL failed"
[ "$FAIL" -eq 0 ] && exit 0 || exit 1