-
Notifications
You must be signed in to change notification settings - Fork 7
π§ͺ Add tests for idstack-learnings-delete #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
savvides
merged 2 commits into
main
from
add-tests-idstack-learnings-delete-2773664691298862766
Aug 6, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -167,6 +167,31 @@ check "missing {{PREAMBLE}} placeholder fails dry-run and generation (sandbox)" | |||||||||||||||
| check "real tree untouched by this suite" \ | ||||||||||||||||
| "[ \"\$(git -C '$IDSTACK_DIR' status --porcelain 2>/dev/null || true)\" = \"\$TREE_BEFORE\" ]" | ||||||||||||||||
|
|
||||||||||||||||
| echo "" | ||||||||||||||||
|
|
||||||||||||||||
| # --- idstack-learnings-delete --- | ||||||||||||||||
| echo "## idstack-learnings-delete" | ||||||||||||||||
|
|
||||||||||||||||
| check "returns error if no arguments provided" \ | ||||||||||||||||
| "! $IDSTACK_DIR/bin/idstack-learnings-delete" | ||||||||||||||||
|
|
||||||||||||||||
| check "returns error if no file exists" \ | ||||||||||||||||
| "rm -f .idstack/learnings.jsonl && ! $IDSTACK_DIR/bin/idstack-learnings-delete somekey" | ||||||||||||||||
|
|
||||||||||||||||
| # Setup data for delete tests | ||||||||||||||||
| $IDSTACK_DIR/bin/idstack-learnings-log '{"skill":"test","type":"fact","key":"key1","insight":"one"}' | ||||||||||||||||
| $IDSTACK_DIR/bin/idstack-learnings-log '{"skill":"test","type":"fact","key":"key2","insight":"two"}' | ||||||||||||||||
| $IDSTACK_DIR/bin/idstack-learnings-log '{"skill":"test","type":"fact","key":"key1","insight":"three"}' | ||||||||||||||||
|
|
||||||||||||||||
| check "returns error if key not found" \ | ||||||||||||||||
| "! $IDSTACK_DIR/bin/idstack-learnings-delete missingkey" | ||||||||||||||||
|
|
||||||||||||||||
| check "deletes the most recent entry with the key when there are duplicates" \ | ||||||||||||||||
| "$IDSTACK_DIR/bin/idstack-learnings-delete key1 && python3 -c \"import json,sys; lines=[json.loads(l) for l in open('.idstack/learnings.jsonl')]; assert len(lines)==2 and lines[0]['key']=='key1' and lines[0]['insight']=='one' and lines[1]['key']=='key2'\"" | ||||||||||||||||
|
|
||||||||||||||||
| check "deletes a specific learning" \ | ||||||||||||||||
| "$IDSTACK_DIR/bin/idstack-learnings-delete key2 && python3 -c \"import json,sys; lines=[json.loads(l) for l in open('.idstack/learnings.jsonl')]; assert len(lines)==1 and lines[0]['key']=='key1'\"" | ||||||||||||||||
|
Comment on lines
+192
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This suggestion introduces three improvements:
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| echo "" | ||||||||||||||||
| echo "Results: $PASS/$TOTAL passed, $FAIL failed" | ||||||||||||||||
| [ "$FAIL" -eq 0 ] && exit 0 || exit 1 | ||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a delete operation fails (e.g., because the key was not found), it is important to verify that the underlying data file remains unmodified and is not corrupted or cleared.
We can enhance this test by asserting that the line count of
.idstack/learnings.jsonlremains exactly3after the failed delete attempt.