Skip to content

chore: introduce better test coverage - #4

Merged
kdihalas merged 3 commits into
mainfrom
chore/tests
Jul 9, 2026
Merged

chore: introduce better test coverage#4
kdihalas merged 3 commits into
mainfrom
chore/tests

Conversation

@kdihalas

@kdihalas kdihalas commented Jul 9, 2026

Copy link
Copy Markdown
Owner

This pull request adds comprehensive tests for the wtcache package, focusing on file system operation behaviors, error propagation, and cache synchronization. It introduces new test files and extends the failingFs helper to simulate failures for a wider range of file system operations. The most important changes are:

Expanded error simulation for testing:

  • The failingFs struct is updated to support forced failures for operations like Remove, RemoveAll, Rename, Mkdir, Chmod, Chown, and Chtimes, 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 for Mkdir, MkdirAll, OpenFile, RemoveAll, Stat, Chmod, Chown, Chtimes, Rename, and more.
  • file_test.go: Introduces tests for the cacheFile type, specifically ensuring that Close behaves correctly for both writable and non-writable files, and that underlying file close errors are properly handled without unwanted side effects.

Test infrastructure improvements:

  • Implements helper types like errCloseFile to 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.

kdihalas added 3 commits July 9, 2026 12:34
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-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.08%. Comparing base (6e5ccd9) to head (6c86086).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kdihalas
kdihalas merged commit a64622a into main Jul 9, 2026
1 check passed
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.

2 participants