Skip to content

More cleanup and increase coverage#71

Merged
andreasjansson merged 38 commits intomainfrom
more-cleanup
Jun 30, 2025
Merged

More cleanup and increase coverage#71
andreasjansson merged 38 commits intomainfrom
more-cleanup

Conversation

@andreasjansson
Copy link
Owner

No description provided.

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.
@andreasjansson andreasjansson merged commit 5529911 into main Jun 30, 2025
6 checks passed
@andreasjansson andreasjansson deleted the more-cleanup branch June 30, 2025 18:20
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