Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ check "no file returns empty" \

echo ""

# --- idstack-learnings-delete ---
echo "## idstack-learnings-delete"

$IDSTACK_DIR/bin/idstack-learnings-log '{"skill":"test","type":"operational","key":"to-delete","insight":"delete me","confidence":9}'
$IDSTACK_DIR/bin/idstack-learnings-log '{"skill":"test","type":"operational","key":"to-keep","insight":"keep me","confidence":9}'

check "deletes specific learning by key" \
"$IDSTACK_DIR/bin/idstack-learnings-delete to-delete && ! grep -q 'to-delete' .idstack/learnings.jsonl && grep -q 'to-keep' .idstack/learnings.jsonl"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using grep to verify the contents of a JSONL file is fragile and can lead to false positives or negatives if the search string (e.g., to-delete) appears in other fields like insight or skill. Since the script already uses python3 for JSON validation in other tests (e.g., lines 37, 57, 77), it is more robust to parse the JSON and verify the specific keys.

Suggested change
"$IDSTACK_DIR/bin/idstack-learnings-delete to-delete && ! grep -q 'to-delete' .idstack/learnings.jsonl && grep -q 'to-keep' .idstack/learnings.jsonl"
"$IDSTACK_DIR/bin/idstack-learnings-delete to-delete && python3 -c \"import json; keys = [json.loads(l)['key'] for l in open('.idstack/learnings.jsonl')]; assert 'to-delete' not in keys and 'to-keep' in keys\""


check "fails if key not found" \
"! $IDSTACK_DIR/bin/idstack-learnings-delete non-existent-key 2>/dev/null"

check "fails on missing arg" \
"! $IDSTACK_DIR/bin/idstack-learnings-delete 2>/dev/null"

check "fails if file missing" \
"rm -f .idstack/learnings.jsonl && ! $IDSTACK_DIR/bin/idstack-learnings-delete to-keep 2>/dev/null"

echo ""

# --- idstack-status ---
echo "## idstack-status"

Expand Down