From f61c436a5aa5a822d2235c057e5ae65b86d326f0 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 6 Jun 2026 01:49:28 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20tests=20for=20idstack-lear?= =?UTF-8?q?nings-delete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds tests for the idstack-learnings-delete command in test/integration-test.sh to cover edge cases, successful deletion, and more. Co-authored-by: savvides <1580637+savvides@users.noreply.github.com> --- test/integration-test.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/integration-test.sh b/test/integration-test.sh index bf45ca7..6749251 100755 --- a/test/integration-test.sh +++ b/test/integration-test.sh @@ -114,6 +114,31 @@ check "dry-run detects stale SKILL.md" \ 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