Skip to content

events: keep the fractional part in DurationSeconds and DurationMinutes - #648

Open
Yeagerist0 wants to merge 1 commit into
aws:mainfrom
Yeagerist0:fix/duration-fractional-values
Open

Yeagerist0 wants to merge 1 commit into
aws:mainfrom
Yeagerist0:fix/duration-fractional-values

Conversation

@Yeagerist0

Copy link
Copy Markdown

UnmarshalJSON decodes into a float64 but then does time.Duration(seconds) * time.Second, which truncates before it multiplies. 1.5 becomes 1s and 1.5 minutes becomes 1m, while MarshalJSON rounds up with math.Ceil.

Multiply in float64 first. Integer inputs behave as before. New tests fail on main (expected: 1.5s, actual: 1s) and pass now; go test ./events is green.

Disclosure: I used Claude Code to help find and write this; I reproduced the bug and ran the tests myself.

UnmarshalJSON decoded the number as a float64 and then converted it to
time.Duration before multiplying, which truncates the fraction: 1.5
seconds became 1s and 1.5 minutes became 1m. Multiply in float64 first.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.04%. Comparing base (4111853) to head (1e52d72).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #648   +/-   ##
=======================================
  Coverage   82.04%   82.04%           
=======================================
  Files          37       37           
  Lines        1487     1487           
=======================================
  Hits         1220     1220           
  Misses        264      264           
  Partials        3        3           

☔ 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.

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