test: add unit tests for gcode/history.py (fixes #66) - #77
Merged
shauryagangrade merged 2 commits intoAug 14, 2026
Conversation
Owner
|
Merged. Thanks for your work here. Give this repo a ⭐ so that we can reach more contributors like you :-) If you would like to contribute to more repos just like this, I recommend: https://github.com/shauryagangrade/intent-drift-skill |
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.
Fixes #66
Description
Adds a comprehensive unit test suite in
tests/test_history.pyforgcode/history.py, covering persistence operations, path sanitization, and error handling.Key Test Cases Included
test_path_sanitization: Verifies session name sanitization replacing unsafe characters.test_save_and_load_round_trip: Verifies saving and reloading LangChain message instances (SystemMessage,HumanMessage,AIMessage).test_save_and_load_tool_call_round_trip: Verifies tool-call →ToolMessagepairing survives a save/load round-trip.test_save_and_load_default_session: Verifies default session loading and saving.test_load_missing_file: Verifies returningNonewhen no session file exists.test_load_corrupt_json&test_load_invalid_message_dict: Verifies returningNonegracefully on malformed JSON or invalid schema.test_clear_session&test_clear_default_session: Verifies deleting session files and safe no-op on missing files.test_save_write_failure_resilience: Verifies handling disk write failures gracefully without raising exceptions.Verification
tests/test_history.pypass — 100% coverage ongcode/history.py.ruff checkandruff format --checkclean.