chore: introduce better test coverage - #4
Merged
Merged
Conversation
Add tests for Mkdir/MkdirAll, OpenFile read/write/truncate paths, Open error and directory branches, RemoveAll/Rename cache-prefix handling, Stat/Chmod/Chown/Chtimes, Close idempotency, default sweep-interval derivation, remote-error propagation, and the cacheFile.Close non-writable/underlying-error branches. Coverage on cache.go+file.go goes from ~50% to ~86%.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4 +/- ##
===========================================
+ Coverage 46.93% 84.08% +37.14%
===========================================
Files 4 4
Lines 245 245
===========================================
+ Hits 115 206 +91
+ Misses 116 32 -84
+ Partials 14 7 -7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
This pull request adds comprehensive tests for the
wtcachepackage, focusing on file system operation behaviors, error propagation, and cache synchronization. It introduces new test files and extends thefailingFshelper to simulate failures for a wider range of file system operations. The most important changes are:Expanded error simulation for testing:
failingFsstruct is updated to support forced failures for operations likeRemove,RemoveAll,Rename,Mkdir,Chmod,Chown, andChtimes, enabling more thorough error-propagation tests.New and extended test coverage:
cache_more_test.go: Adds a large suite of tests covering cache behavior for directory creation, file operations, error propagation, cache invalidation, and synchronization between memory and remote file systems. This includes tests forMkdir,MkdirAll,OpenFile,RemoveAll,Stat,Chmod,Chown,Chtimes,Rename, and more.file_test.go: Introduces tests for thecacheFiletype, specifically ensuring thatClosebehaves correctly for both writable and non-writable files, and that underlying file close errors are properly handled without unwanted side effects.Test infrastructure improvements:
errCloseFileto simulate file close errors for robust negative testing scenarios.These changes significantly improve the reliability and coverage of the test suite for the write-through cache file system implementation.