Skip to content

Commit dbb88bc

Browse files
committed
fixed tests for bitlesson-select-routing
1 parent 0844648 commit dbb88bc

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

tests/test-bitlesson-select-routing.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,25 @@ Source Rounds: 0
4545
EOF
4646
}
4747

48+
create_real_humanize_bitlesson() {
49+
local dir="$1"
50+
mkdir -p "$dir/.humanize"
51+
cat > "$dir/.humanize/bitlesson.md" <<'EOF'
52+
# BitLesson Knowledge Base
53+
## Entries
54+
55+
## Lesson: Avoid tracker drift
56+
Lesson ID: BL-20260315-tracker-drift
57+
Scope: goal-tracker.md
58+
Problem Description: Tracker diverges from actual task status.
59+
Root Cause: Status rows are not updated after verification.
60+
Solution: Update tracker rows immediately after each verification step.
61+
Constraints: Keep tracker edits minimal.
62+
Validation Evidence: Verified in test fixture.
63+
Source Rounds: 0
64+
EOF
65+
}
66+
4867
# Helper: create a mock codex binary that outputs valid bitlesson-selector format
4968
create_mock_codex() {
5069
local bin_dir="$1"
@@ -121,7 +140,7 @@ echo "--- Test 1: gpt-* model routes to codex ---"
121140
echo ""
122141

123142
setup_test_dir
124-
create_real_bitlesson "$TEST_DIR"
143+
create_real_humanize_bitlesson "$TEST_DIR"
125144
BIN_DIR="$TEST_DIR/bin"
126145
create_mock_codex "$BIN_DIR"
127146
mkdir -p "$TEST_DIR/.humanize"
@@ -150,7 +169,7 @@ echo "--- Test 1b: gpt-* codex path passes stdin prompt via trailing '-' ---"
150169
echo ""
151170

152171
setup_test_dir
153-
create_mock_bitlesson "$TEST_DIR"
172+
create_real_humanize_bitlesson "$TEST_DIR"
154173
BIN_DIR="$TEST_DIR/bin"
155174
STDIN_FILE="$TEST_DIR/codex-stdin.txt"
156175
create_recording_mock_codex "$BIN_DIR" "$STDIN_FILE"
@@ -185,7 +204,7 @@ echo "--- Test 2: haiku model routes to claude ---"
185204
echo ""
186205

187206
setup_test_dir
188-
create_real_bitlesson "$TEST_DIR"
207+
create_real_humanize_bitlesson "$TEST_DIR"
189208
BIN_DIR="$TEST_DIR/bin"
190209
create_mock_claude "$BIN_DIR"
191210
mkdir -p "$TEST_DIR/.humanize"
@@ -214,7 +233,7 @@ echo "--- Test 3: sonnet model routes to claude ---"
214233
echo ""
215234

216235
setup_test_dir
217-
create_real_bitlesson "$TEST_DIR"
236+
create_real_humanize_bitlesson "$TEST_DIR"
218237
BIN_DIR="$TEST_DIR/bin"
219238
create_mock_claude "$BIN_DIR"
220239
mkdir -p "$TEST_DIR/.humanize"
@@ -243,7 +262,7 @@ echo "--- Test 4: OPUS (uppercase) model routes to claude ---"
243262
echo ""
244263

245264
setup_test_dir
246-
create_real_bitlesson "$TEST_DIR"
265+
create_real_humanize_bitlesson "$TEST_DIR"
247266
BIN_DIR="$TEST_DIR/bin"
248267
create_mock_claude "$BIN_DIR"
249268
mkdir -p "$TEST_DIR/.humanize"
@@ -272,7 +291,7 @@ echo "--- Test 5: Unknown model exits non-zero with error ---"
272291
echo ""
273292

274293
setup_test_dir
275-
create_real_bitlesson "$TEST_DIR"
294+
create_real_humanize_bitlesson "$TEST_DIR"
276295
mkdir -p "$TEST_DIR/.humanize"
277296
printf '{"bitlesson_model": "unknown-xyz-model"}' > "$TEST_DIR/.humanize/config.json"
278297

@@ -298,7 +317,7 @@ echo "--- Test 6: gpt-* model with missing codex binary exits non-zero ---"
298317
echo ""
299318

300319
setup_test_dir
301-
create_real_bitlesson "$TEST_DIR"
320+
create_real_humanize_bitlesson "$TEST_DIR"
302321
mkdir -p "$TEST_DIR/.humanize"
303322
printf '{"bitlesson_model": "gpt-4o"}' > "$TEST_DIR/.humanize/config.json"
304323
# Use a bin dir that contains a stub claude but NOT codex.
@@ -334,7 +353,7 @@ echo "--- Test 7: haiku model falls back to codex when claude binary is missing
334353
echo ""
335354

336355
setup_test_dir
337-
create_real_bitlesson "$TEST_DIR"
356+
create_real_humanize_bitlesson "$TEST_DIR"
338357
mkdir -p "$TEST_DIR/.humanize"
339358
printf '{"bitlesson_model": "haiku"}' > "$TEST_DIR/.humanize/config.json"
340359
# Use a bin dir that contains a stub codex but NOT claude.
@@ -409,7 +428,7 @@ stdout_out=$(CLAUDE_PROJECT_DIR="$TEST_DIR" XDG_CONFIG_HOME="$TEST_DIR/no-user"
409428
bash "$BITLESSON_SELECT" \
410429
--task "Any task" \
411430
--paths "README.md" \
412-
--bitlesson-file "$TEST_DIR/bitlesson.md" 2>/dev/null) || exit_code=$?
431+
--bitlesson-file "$TEST_DIR/.humanize/bitlesson.md" 2>/dev/null) || exit_code=$?
413432

414433
if [[ $exit_code -eq 0 ]] && echo "$stdout_out" | grep -q "LESSON_IDS: NONE" && echo "$stdout_out" | grep -q "no recorded lessons"; then
415434
pass "Placeholder BitLesson file returns NONE without invoking a model"

0 commit comments

Comments
 (0)