🧪 test: add integration tests for idstack-learnings-promote#37
Conversation
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>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request adds integration tests for the idstack-learnings-promote command in test/integration-test.sh. The feedback recommends improving the robustness of the inline Python scripts by passing the $FAKE_HOME path as a command-line argument instead of embedding it directly in the single-quoted Python code string, which could fail if the path contains special characters.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| "! $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'\"" |
There was a problem hiding this comment.
Passing the $FAKE_HOME path directly inside the Python code string can lead to syntax errors or failures if the path contains single quotes or other special characters (since it is enclosed in single quotes '...' in the Python snippet).
A more robust approach is to pass the file path as a command-line argument to Python and access it via sys.argv[1]. This keeps the Python code string static and avoids quoting/escaping issues.
| "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'\"" | |
| "HOME=\"$FAKE_HOME\" $IDSTACK_DIR/bin/idstack-learnings-promote my-key && [ -f \"$FAKE_HOME/.idstack/global/learnings.jsonl\" ] && python3 -c \"import sys, json; d=json.loads(open(sys.argv[1]).readlines()[-1]); assert d['_source_project'] == 'unknown'\" \"$FAKE_HOME/.idstack/global/learnings.jsonl\"" |
| 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'\"" |
There was a problem hiding this comment.
Similarly to the previous test, passing the $FAKE_HOME path directly inside the Python code string can fail if the path contains single quotes. Passing it as an argument via sys.argv[1] is much more robust.
| "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'\"" | |
| "HOME=\"$FAKE_HOME\" $IDSTACK_DIR/bin/idstack-learnings-promote key2 && python3 -c \"import sys, json; d=json.loads(open(sys.argv[1]).readlines()[-1]); assert d['_source_project'] == 'my-test-proj'\" \"$FAKE_HOME/.idstack/global/learnings.jsonl\"" |
🎯 What: Added tests for the
idstack-learnings-promotescript to improve codebase coverage and reliability, preventing regressions.📊 Coverage: Covered edge cases such as missing key, missing learnings file, missing learning key, and happy paths for correctly promoting the learning with and without known source projects.
✨ Result: Improved test coverage and reliability of the
idstack-learnings-promotescript.PR created automatically by Jules for task 2207205292019000283 started by @savvides