Repository navigation
test(session): cover the reachable error paths of the durability fix - #476
Merged
Merged
Conversation
Codecov flagged 11 uncovered added lines. These are the ones a test can actually reach: a missing session directory must fail the open rather than look like a successful write, a closed handle must fail leftJoin's stat instead of passing silently, and rewriteEvents/writeFileAtomic must report a missing parent directory. The lines still uncovered are the branches that require the operating system to fail a syscall that succeeds in a test — Sync returning an error, ReadAt failing on a readable file, MkdirAll/CreateTemp on a healthy filesystem. Covering those needs a fault-injecting filesystem, which is a dependency this change does not justify; left uncovered deliberately. Signed-off-by: pi <dimetron@me.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #476 +/- ##
=======================================
Coverage 91.58% 91.59%
=======================================
Files 391 391
Lines 50292 50292
=======================================
+ Hits 46062 46065 +3
+ Misses 4224 4221 -3
Partials 6 6 ☔ 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.
Follow-up to #475, which merged before this commit's CI run finished. The
durability fix is on
main; only its error-path tests were left behind.Tests only — no production code changes.
What this adds
Four error paths of the #475 fix that had no coverage:
TestAppendEventToFile_ErrorWhenSessionDirMissingTestRewriteEvents_ErrorWhenSessionDirMissingTestWriteFileAtomic_ErrorWhenDirMissingTestLeftJoin_ErrorOnClosedFileThe
leftJoinone matters most: if that error were swallowed, the next appendwould concatenate onto a torn tail and corrupt two records instead of one.
Verified
TestLeftJoin_ErrorOnClosedFilefails when the behaviour regresses — changed thereturn data, errtoreturn data, niland the guard went red withleftJoin() = nil error on a closed file, want the stat failure, then restored.go test ./internal/session/,go vet,golangci-lintall clean.Deliberately not covered
The remaining uncovered lines in
store.goare branches that need the OS tofail a syscall that succeeds in a test —
Syncreturning an error,ReadAtfailing on a readable file,
MkdirAll/CreateTempon a healthy filesystem.Covering those needs a fault-injecting filesystem, which this change does not
justify. Note also that
TestAppendEventToFile_IsSyncedstill passes with theSynccall removed: nothing in-process simulates power loss, so that assertionverifies the file is complete and newline-terminated, not that it was synced.