test(time): cover Time.UnmarshalJSON error path (100% coverage) - #215
Merged
Merged
Conversation
#208 added atomic.Time.UnmarshalJSON but its test only exercised valid input, so the error branch (`return err`) was never executed. That left package coverage at 99.6%, below the 100% target in .codecov.yml. Add an UnmarshalJSONError subtest that feeds a well-formed JSON string which isn't a valid RFC 3339 timestamp, asserting the decode error is propagated and the wrapped value is left untouched. Restores coverage to 100%. Signed-off-by: Justin Hwang <justinhwang@uber.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #215 +/- ##
===========================================
+ Coverage 99.51% 100.00% +0.48%
===========================================
Files 23 23
Lines 410 410
===========================================
+ Hits 408 410 +2
+ Misses 1 0 -1
+ Partials 1 0 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
justinhwang
enabled auto-merge (squash)
September 17, 2026 21:46
rabbbit
approved these changes
Sep 18, 2026
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
#208 added
atomic.Time.MarshalJSON/UnmarshalJSON, but itsTestTimeJSONonly exercised valid JSON. The error branch ofUnmarshalJSON(return err) was never executed:That dropped package coverage to 99.6%, below the 100% target in
.codecov.yml.Change
Adds an
UnmarshalJSONErrorsubtest toTestTimeJSONthat feeds a well-formed JSON string which isn't a valid RFC 3339 timestamp. It asserts the decode error is propagated and that the wrapped value is left untouched.Note: unlike the
Duration/Bool/Stringerror tests, this can't reuse theassertErrorJSONUnmarshalTypehelper —Timedelegates totime.Time.UnmarshalJSON, which returns a*time.ParseErrorrather than a*json.UnmarshalTypeError.Verification
go test -cover .→ 100.0% of statements (was 99.6%)make test(race suite) passesgofmt -sandgo vet ./...cleanTest-only change; no CHANGELOG entry (not user-facing).
Before opening your pull request, please make sure that you've:
make test); and finally,make lint). —gofmt/go vetclean;golintinstall fails on this Go toolchain (pre-existing, unrelated)🤖 Generated with Claude Code