Skip to content

test: unit tests for pure Go functions in web/api/treadmill#62

Merged
rwlove merged 1 commit into
mainfrom
test/go-pure-funcs
Jul 2, 2026
Merged

test: unit tests for pure Go functions in web/api/treadmill#62
rwlove merged 1 commit into
mainfrom
test/go-pure-funcs

Conversation

@rwlove

@rwlove rwlove commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Adds ~40 tests for functions that took no store/network/time-sensitive inputs and were previously untested (only healthstats and the treadmill session detector had tests).

  • web/colors_test.gohslToHex anchors + fuzz, nextExerciseColor determinism, needsColorBackfill / collectColors
  • web/index_test.gobuildGroupList ordering (with empty-group edge), sortExsByFrequency frequency + Place tiebreak + window
  • api/health_test.goparseHealthEnvelope metadata stripping / counts / malformed / dropped-untimeable, healthRecordFromElement scalar + Extra + fallback, firstTime / firstNumeric priorities
  • treadmill/parse_test.goparseWatts envelope / raw / null-value must fail / missing-value / whitespace / garbage

Test plan

  • 45 pass across the three packages (~5 before)

🤖 Generated with Claude Code

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>
@rwlove rwlove merged commit 6243aca into main Jul 2, 2026
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.

1 participant