fix(generator): drop incorrect distinctness assert in TestPlanetRandomName #19

Merged
developer merged 1 commits from feature/fix-flaky-planet-random-name into development 2026-05-19 08:15:46 +00:00
Owner

Summary

  • RandomName builds the suffix as two independent rand.Intn(1000) calls, so the halves collide on ~0.1% of runs. The test asserted g[2] != g[3], which is a property RandomName does not promise and does not need to (planet name collisions across planets are already tolerated by generate_game.go). Drop the assert; keep the format + class-prefix checks.
  • Confirmed offending failure on PR #17's first #199 go-unit.yaml (collided on "0074").

Test plan

  • go test ./game/internal/generator/ -run TestPlanetRandomName -count=200 — 1400 sub-runs without a failure (prior version's flake probability would have surfaced ~once on average)
  • Gitea go-unit green on this branch (#209)
## Summary - `RandomName` builds the suffix as two independent `rand.Intn(1000)` calls, so the halves collide on ~0.1% of runs. The test asserted `g[2] != g[3]`, which is a property `RandomName` does not promise and does not need to (planet name collisions across planets are already tolerated by `generate_game.go`). Drop the assert; keep the format + class-prefix checks. - Confirmed offending failure on PR #17's first `#199 go-unit.yaml` (collided on `"0074"`). ## Test plan - [x] `go test ./game/internal/generator/ -run TestPlanetRandomName -count=200` — 1400 sub-runs without a failure (prior version's flake probability would have surfaced ~once on average) - [x] Gitea go-unit green on this branch (#209)
developer added 1 commit 2026-05-19 08:15:38 +00:00
fix(generator): drop incorrect distinctness assert in TestPlanetRandomName
Tests · Go / test (push) Successful in 1m54s
Tests · Integration / integration (pull_request) Successful in 1m42s
Tests · Go / test (pull_request) Successful in 2m2s
3d06f49f3c
`RandomName` builds the suffix as two independent `rand.Intn(1000)`
calls, so the two 4-digit halves collide on ~0.1% of runs. The
sub-test asserted `g[2] != g[3]`, which flakes whenever the same
value lands twice — once per ~1000 sub-runs per class, so across
the seven `PlanetClass` rows the integration suite hit it on
`#199 go-unit.yaml` against `feature/subscribe-events-heartbeat`
(`"0074"` collision).

Distinctness is not a property `RandomName` promises and is not
load-bearing for callers: `game/internal/controller/generate_game.go`
uses these names for planet labels and already tolerates duplicate
names across planets, so collisions inside one name are no worse
than collisions between names. Drop the assert; keep the format and
class-prefix checks, which are the actual contract.

Stress-tested with `-count=200`: 200 consecutive iterations × 7
classes = 1400 sub-runs without a single failure where the prior
version's flake probability would have surfaced ~once on average.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
developer merged commit 65c0fbb87d into development 2026-05-19 08:15:46 +00:00
developer deleted branch feature/fix-flaky-planet-random-name 2026-05-19 08:15:46 +00:00
Sign in to join this conversation.