Skip to content

🧪 test: add integration tests for idstack-learnings-promote#37

Open
savvides wants to merge 1 commit into
mainfrom
add-tests-idstack-learnings-promote-2207205292019000283
Open

🧪 test: add integration tests for idstack-learnings-promote#37
savvides wants to merge 1 commit into
mainfrom
add-tests-idstack-learnings-promote-2207205292019000283

Conversation

@savvides

@savvides savvides commented Jun 6, 2026

Copy link
Copy Markdown
Owner

🎯 What: Added tests for the idstack-learnings-promote script 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-promote script.


PR created automatically by Jules for task 2207205292019000283 started by @savvides

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>
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread test/integration-test.sh
"! $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'\""

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

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.

Suggested change
"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\""

Comment thread test/integration-test.sh
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'\""

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

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.

Suggested change
"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\""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant