test: add unit coverage for ci writer helpers#3569
test: add unit coverage for ci writer helpers#3569Ankitsinghsisodya wants to merge 2 commits intoknative:mainfrom
Conversation
Add tests for the fileWriter (DefaultWorkflowWriter) and BufferWriter implementations in cmd/ci/writer.go. Covered: - Write creates all missing parent directories - Write overwrites existing file content (no append) - Exist returns false before any write - Exist returns true after a successful write - BufferWriter.Write stores path and resets buffer on each call - BufferWriter.Exist reflects buffer non-emptiness Fixes zero-coverage on writer.go:26 and writer.go:38.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ankitsinghsisodya The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Ankitsinghsisodya. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Pull request overview
Adds unit tests for the CI workflow writer helpers in cmd/ci/writer.go, addressing the lack of coverage noted in #3567.
Changes:
- Introduces
cmd/ci/writer_test.gowith unit tests coveringfileWriter.Write,fileWriter.Exist, and theBufferWritertest double. - Verifies parent directory creation, overwrite (truncate) behavior, and in-memory writer semantics (path recording + buffer reset).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3569 +/- ##
==========================================
+ Coverage 55.52% 56.24% +0.72%
==========================================
Files 180 180
Lines 20465 20465
==========================================
+ Hits 11363 11511 +148
+ Misses 7902 7755 -147
+ Partials 1200 1199 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
test: add unit tests for BufferWriter in cmd/ci
Closes #3567
Matches the draft in
pr1/issue.md.What this PR does
Adds
cmd/ci/writer_test.go— a new test file forcmd/ci/writer.go.Before this change, the
BufferWritertest double had zero direct testcoverage. This PR adds focused tests for the behaviours other
cmd/citestsdepend on: recording the path passed to
Write, reporting existence based onbuffer content, and resetting the buffer on consecutive writes.
Changes
cmd/ci/writer_test.goBufferWriterTests added
How to verify
go test ./cmd/ci/... -v -run TestBufferWriterExpected output: 3 tests PASS,
ok knative.dev/func/cmd/ci.Checklist
make testpassesmake checkpasses