test(storage): cover disk storage initialization#4195
Open
piotr-roslaniec wants to merge 1 commit into
Open
Conversation
pkg/storage had no test coverage. Add tests for the disk storage bootstrapper, focused on the behavior that gives the package its purpose: separating sensitive keystore data from restart-recoverable work data into two sibling directories, and rooting each persistence handle under the correct one. Covers directory layout, restart idempotency, the missing-parent error path (EnsureDirectoryExists creates a single level only), and that key store and work persistence never leak into each other's directory. Raises package coverage from 0% to ~88%. The file is force-added: .gitignore's unanchored 'storage/' rule (added 2026, for the runtime storage directory) also matches the pkg/storage/ source package. storage.go predates that rule and is grandfathered in; force-add is the surgical way to track a new file here without changing shared ignore semantics.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds storage package tests covering root directory creation, idempotent initialization, missing-parent errors, persistence path routing, and missing intermediate-directory errors. ChangesStorage initialization tests
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
What
Adds a test suite for
pkg/storage, which previously had 0% coverage. Raises package coverage to ~88%.The tests focus on the behavior that gives the package its reason to exist: separating sensitive keystore data (whose loss is "a serious protocol violation" per the code) from restart-recoverable work data into two sibling directories, and rooting each persistence handle under the correct one.
Covered:
Initializecreates thekeystoreandworkdirectory layout under the configured root.Initializere-run against existing directories does not error).EnsureDirectoryExistsuses single-levelos.Mkdir).Verification
go test ./pkg/storage/passes (6 tests);gofmt -l,go vet, andstaticcheck -SA1019(theclient-lintCI gate) all clean.Note for reviewers: the test file is force-added
.gitignorehas an unanchoredstorage/rule (added in 2026, intended for the client's runtime storage directory) that also matches thepkg/storage/source package.storage.gopredates that rule (added 2022) and is grandfathered in as tracked, so it wasn't caught; a brand-new file here is. The file was added withgit add -fand is now tracked normally (CI checks out tracked files regardless of.gitignore).I kept this PR surgical and did not change the shared ignore rule. If you'd prefer a permanent fix, a one-line follow-up would anchor the rule to the runtime dir (
storage/->/storage/) or add an exception (!/pkg/storage/). Happy to open that separately.Summary by CodeRabbit