From fe9740f4268f63e98618625d9a11c3c7d967d0b8 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:48:34 +0000 Subject: [PATCH] test: add integration tests for idstack-learnings-promote This commit adds integration tests to test/integration-test.sh to cover the functionality of the bin/idstack-learnings-promote script. Tests mock the global directory and verify failure conditions (missing inputs, files, keys) as well as successful promotion and tagging (with and without known project). Co-authored-by: savvides <1580637+savvides@users.noreply.github.com> --- test/integration-test.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/integration-test.sh b/test/integration-test.sh index bf45ca7..1b3f1e3 100755 --- a/test/integration-test.sh +++ b/test/integration-test.sh @@ -115,5 +115,34 @@ check "regenerate fixes staleness" \ "$IDSTACK_DIR/bin/idstack-gen-skills && $IDSTACK_DIR/bin/idstack-gen-skills --dry-run" echo "" +# --- idstack-learnings-promote --- +echo "## idstack-learnings-promote" + +FAKE_HOME="$TEST_DIR/fake_home" +mkdir -p "$FAKE_HOME" + +check "fails if no key provided" \ + "! $IDSTACK_DIR/bin/idstack-learnings-promote" + +check "fails if no local learnings found" \ + "rm -f .idstack/learnings.jsonl && ! $IDSTACK_DIR/bin/idstack-learnings-promote my-key" + +mkdir -p .idstack +echo '{"skill":"test-skill","key":"my-key","type":"pattern","insight":"hello"}' > .idstack/learnings.jsonl + +check "fails if key not found" \ + "! $IDSTACK_DIR/bin/idstack-learnings-promote wrong-key" + +check "promotes learning with unknown project" \ + "HOME=\"$FAKE_HOME\" $IDSTACK_DIR/bin/idstack-learnings-promote my-key && [ -f \"$FAKE_HOME/.idstack/global/learnings.jsonl\" ] && python3 -c \"import json; d=json.loads(open('$FAKE_HOME/.idstack/global/learnings.jsonl').readlines()[-1]); assert d['_source_project'] == 'unknown'\"" + +echo '{"project_name":"my-test-proj"}' > .idstack/project.json +echo '{"skill":"test-skill","key":"key2","type":"pattern","insight":"hello2"}' >> .idstack/learnings.jsonl + +check "promotes learning with known project" \ + "HOME=\"$FAKE_HOME\" $IDSTACK_DIR/bin/idstack-learnings-promote key2 && python3 -c \"import json; d=json.loads(open('$FAKE_HOME/.idstack/global/learnings.jsonl').readlines()[-1]); assert d['_source_project'] == 'my-test-proj'\"" + +echo "" + echo "Results: $PASS/$TOTAL passed, $FAIL failed" [ "$FAIL" -eq 0 ] && exit 0 || exit 1