test: unit tests for pure Go functions in web/api/treadmill#62
Merged
Conversation
Adds coverage for functions that took no store/network/time-sensitive inputs and were previously untested (only healthstats and treadmill session detector had tests). - internal/web/colors_test.go: hslToHex anchors (red/green/blue/black/ white/grey) + always-well-formed sweep, nextExerciseColor determinism and small-N distinctness, needsColorBackfill/collectColors edges - internal/web/index_test.go: buildGroupList first-seen ordering (with empty-group edge case), sortExsByFrequency ordering + Place tiebreak + window respect - internal/api/health_test.go: parseHealthEnvelope metadata stripping, per-type counts, malformed root, dropped-untimeable records; healthRecordFromElement scalar mapping + Extra preservation + timestamp stripping from Extra + unmapped-type fallback via firstNumeric; firstTime priority, firstNumeric key order - internal/treadmill/parse_test.go: parseWatts envelope + raw + null- value + missing-value (both must NOT synthesise 0 W) + whitespace + garbage 45 tests pass across the three packages (~5 before this commit). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Adds ~40 tests for functions that took no store/network/time-sensitive inputs and were previously untested (only
healthstatsand the treadmill session detector had tests).web/colors_test.go—hslToHexanchors + fuzz,nextExerciseColordeterminism,needsColorBackfill/collectColorsweb/index_test.go—buildGroupListordering (with empty-group edge),sortExsByFrequencyfrequency + Place tiebreak + windowapi/health_test.go—parseHealthEnvelopemetadata stripping / counts / malformed / dropped-untimeable,healthRecordFromElementscalar + Extra + fallback,firstTime/firstNumericprioritiestreadmill/parse_test.go—parseWattsenvelope / raw / null-value must fail / missing-value / whitespace / garbageTest plan
🤖 Generated with Claude Code