Skip to content

🧪 Add integration test for idstack-learnings-promote#30

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

🧪 Add integration test for idstack-learnings-promote#30
savvides wants to merge 1 commit into
mainfrom
add-tests-idstack-learnings-promote-9625672838325855957

Conversation

@savvides
Copy link
Copy Markdown
Owner

🎯 What: Added missing integration tests for the bin/idstack-learnings-promote script to address a testing gap.
📊 Coverage: Covered scenarios include:

  • Failing gracefully when no key is provided.
  • Failing gracefully when local learnings file is absent.
  • Failing gracefully when the requested key is missing.
  • Successfully promoting a learning, saving it to global learnings, and tagging it correctly with _promoted and _source_project.
    Result: Improved test coverage and verification for the idstack-learnings-promote bash script.

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

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.

Copy link
Copy Markdown

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

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 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.

Comment thread test/integration-test.sh
echo "## idstack-learnings-promote"

check "fails if no key provided" \
"! $IDSTACK_DIR/bin/idstack-learnings-promote 2>/dev/null"
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

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.

Suggested change
"! $IDSTACK_DIR/bin/idstack-learnings-promote 2>/dev/null"
"! \"$IDSTACK_DIR/bin/idstack-learnings-promote\" 2>/dev/null"

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

Quote $IDSTACK_DIR to prevent issues with paths containing spaces. This is consistent with other parts of the test suite (e.g., line 34).

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

Comment thread test/integration-test.sh
echo '{"project_name": "Test Project"}' > .idstack/project.json

check "fails if key not found" \
"! $IDSTACK_DIR/bin/idstack-learnings-promote 'missingkey' 2>/dev/null"
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

Quote $IDSTACK_DIR to ensure the script path is correctly parsed even if the directory name contains spaces.

Suggested change
"! $IDSTACK_DIR/bin/idstack-learnings-promote 'missingkey' 2>/dev/null"
"! \"$IDSTACK_DIR/bin/idstack-learnings-promote\" 'missingkey' 2>/dev/null"

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

This test case can be improved for robustness and completeness:

  1. Quoting: Quote HOME, $IDSTACK_DIR, and $TEST_DIR to handle spaces in paths.
  2. Readability: Use relative paths (e.g., .idstack/...) since the script already changes the working directory to $TEST_DIR.
  3. Robustness: Use tail -n 1 to verify the most recently added entry, which is safer than readline() if the file contains multiple entries.
  4. Verification: Assert that the original learning content (e.g., the insight field) is preserved during the promotion process.
Suggested change
"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'\""

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