More cleanup and increase coverage#71
Merged
andreasjansson merged 38 commits intomainfrom Jun 30, 2025
Merged
Conversation
Replace dolist with cl-loop to fix invalid cl-return usage. The cl-return statements were invalid outside of cl-loop context. Now using cl-loop with 'until' clause to stop at &rest parameters and 'unless' to skip &optional markers, eliminating the need for cl-return entirely.
Replace let-bound variables with cl-loop's 'for' clauses and replace cond with cl-loop's 'if'/'else' constructs. This is much more idiomatic to the cl-loop style and eliminates nested let and cond expressions.
cl-loop's collect clause builds the list in iteration order, so nreverse is no longer needed. The original code needed it because push builds lists in reverse order, but collect preserves the natural iteration order.
The unless clause was skipping iterations entirely including variable bindings. Changed to use when clause to only process real parameters and skip &optional/&rest markers cleanly.
The when clause wasn't preventing variable binding for &optional markers. Reverted to simple approach with unless and collect clauses only.
…-request Added comprehensive tests for: - greger with-context functionality: `(greger t)` - tests buffer creation, window splitting, and context insertion - greger-set-model: tests model selection and variable setting - greger-debug-request: tests request data debugging and JSON file creation
Modified greger-debug-request to automatically open the created JSON file in a new buffer after saving the request data, making it easier to inspect the debugging output.
Updated the test to verify that greger-debug-request now opens the created JSON file after saving it, and mock the find-file function to track this behavior.
The test was failing because greger-mode wasn't properly mocked. Added greger-mode mock and ensured buffer content is properly handled in the test by allowing the greger function to work with the returned buffer.
Added greger-mode mock to the second test as well to ensure consistency and prevent mode setup issues during testing.
Simplified the test to be more robust by testing the core logic without requiring all greger dependencies. The test now verifies the basic functionality of greger with-context in a more controlled way.
Simplified this test as well to be more robust and focus on testing the difference between with-context and without-context behavior.
Added tests using real temporary git repositories to verify: - Basic git staging and committing functionality - Multiple file staging and committing - Error handling for non-git directories - Chat buffer integration when tracked by git - Chat buffer ignoring when not tracked - Error cases (staging failures, commit failures) - Integration with various scenarios
The greger-stdlib--git-stage-and-commit function returns error messages as strings rather than signaling errors due to its condition-case wrapper. Updated the test to verify the returned error message string instead of expecting a signaled error.
Updated the staging failure test to verify that the function returns an error message string rather than signaling an error, matching the actual behavior of the function's condition-case wrapper.
The function returns the direct error message for non-git directories, not wrapped with 'Git operation failed'. Updated test to check for the actual error message format.
The staging failure also returns the direct error message, not wrapped with 'Git operation failed'. Updated test to check for the actual error message format.
Added test to verify behavior when trying to commit with an empty commit message, which should fail with git and return an error message.
The commit failure also returns the direct error message, not wrapped with 'Git operation failed'. Updated test to check for the actual error message format.
Replaced the mock-based test with a realistic test that: - Creates a real temporary file with content - Opens it in a buffer and positions cursor at a specific location - Actually calls (greger t) to test the with-context functionality - Verifies the generated greger buffer contains correct context information - Properly cleans up the temporary file
Fixed the test by: - Using a simpler approach with proper requires - Removing complex mocking of window functions - Testing only the essential context functionality - Ensuring proper cleanup of resources
Changed expected column from 10 to 9 to match the actual cursor position after moving forward 9 characters. Also updated the test assertion for column to match.
Updated the expected column number from 10 to 9 in the test assertions and the buffer content checks to match the actual cursor position.
Updated the buffer content check to expect "and column 9" instead of "and column 10" to match the actual cursor position.
Updated the test to: - Create a temp file with content - Navigate to a specific point in the buffer - Call (greger-buffer t) from within that temp file - Verify the content of the resulting greger buffer This matches exactly what was requested in the instructions.
Updated the test to call (greger t) instead of (greger-buffer t) and verify the content of the resulting greger buffer that gets created with context information from the temp file.
Simplified the test to print the buffer content for debugging and focus on the core functionality without complex mocking that might interfere with the actual context generation.
Removed debug message and simplified the test now that it's working correctly. The test now properly calls (greger t) and verifies the content of the resulting greger buffer with context information.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.