🧪 Add integration test for idstack-learnings-promote#30
Conversation
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 introduces integration tests for the idstack-learnings-promote utility, covering failure cases for missing keys or files and verifying successful promotion with metadata tagging. The review feedback focuses on improving the robustness of the shell script by quoting path variables to handle spaces and refining the verification logic for promoted entries.
| echo "## idstack-learnings-promote" | ||
|
|
||
| check "fails if no key provided" \ | ||
| "! $IDSTACK_DIR/bin/idstack-learnings-promote 2>/dev/null" |
There was a problem hiding this comment.
The variable $IDSTACK_DIR should be quoted to ensure the path is handled correctly if it contains spaces. This improves the robustness of the test script across different environments.
| "! $IDSTACK_DIR/bin/idstack-learnings-promote 2>/dev/null" | |
| "! \"$IDSTACK_DIR/bin/idstack-learnings-promote\" 2>/dev/null" |
| "! $IDSTACK_DIR/bin/idstack-learnings-promote 2>/dev/null" | ||
|
|
||
| check "fails if no local learnings found" \ | ||
| "rm -f .idstack/learnings.jsonl && ! $IDSTACK_DIR/bin/idstack-learnings-promote 'testkey' 2>/dev/null" |
There was a problem hiding this comment.
Quote $IDSTACK_DIR to prevent issues with paths containing spaces. This is consistent with other parts of the test suite (e.g., line 34).
| "rm -f .idstack/learnings.jsonl && ! $IDSTACK_DIR/bin/idstack-learnings-promote 'testkey' 2>/dev/null" | |
| "rm -f .idstack/learnings.jsonl && ! \"$IDSTACK_DIR/bin/idstack-learnings-promote\" 'testkey' 2>/dev/null" |
| echo '{"project_name": "Test Project"}' > .idstack/project.json | ||
|
|
||
| check "fails if key not found" \ | ||
| "! $IDSTACK_DIR/bin/idstack-learnings-promote 'missingkey' 2>/dev/null" |
There was a problem hiding this comment.
| "! $IDSTACK_DIR/bin/idstack-learnings-promote 'missingkey' 2>/dev/null" | ||
|
|
||
| check "promotes learning and tags it" \ | ||
| "HOME=$TEST_DIR $IDSTACK_DIR/bin/idstack-learnings-promote 'testkey' && [ -f $TEST_DIR/.idstack/global/learnings.jsonl ] && python3 -c \"import json; d=json.loads(open('$TEST_DIR/.idstack/global/learnings.jsonl').readline()); assert d['key']=='testkey' and d['_promoted']==True and d['_source_project']=='Test Project'\"" |
There was a problem hiding this comment.
This test case can be improved for robustness and completeness:
- Quoting: Quote
HOME,$IDSTACK_DIR, and$TEST_DIRto handle spaces in paths. - Readability: Use relative paths (e.g.,
.idstack/...) since the script already changes the working directory to$TEST_DIR. - Robustness: Use
tail -n 1to verify the most recently added entry, which is safer thanreadline()if the file contains multiple entries. - Verification: Assert that the original learning content (e.g., the
insightfield) is preserved during the promotion process.
| "HOME=$TEST_DIR $IDSTACK_DIR/bin/idstack-learnings-promote 'testkey' && [ -f $TEST_DIR/.idstack/global/learnings.jsonl ] && python3 -c \"import json; d=json.loads(open('$TEST_DIR/.idstack/global/learnings.jsonl').readline()); assert d['key']=='testkey' and d['_promoted']==True and d['_source_project']=='Test Project'\"" | |
| "HOME=\"$TEST_DIR\" \"$IDSTACK_DIR/bin/idstack-learnings-promote\" 'testkey' && [ -f .idstack/global/learnings.jsonl ] && tail -n 1 .idstack/global/learnings.jsonl | python3 -c \"import json,sys; d=json.load(sys.stdin); assert d['key']=='testkey' and d['insight']=='test insight' and d['_promoted'] is True and d['_source_project']=='Test Project'\"" |
🎯 What: Added missing integration tests for the
bin/idstack-learnings-promotescript to address a testing gap.📊 Coverage: Covered scenarios include:
_promotedand_source_project.✨ Result: Improved test coverage and verification for the
idstack-learnings-promotebash script.PR created automatically by Jules for task 9625672838325855957 started by @savvides