Skip to content

Test cleanup: split oversized test files, fix three weak tests (tests only) - #107

Merged
floatdrop merged 5 commits into
draft-20from
cleanup/tests-2
Sep 26, 2026
Merged

floatdrop merged 5 commits into
draft-20from
cleanup/tests-2

Conversation

@floatdrop

Copy link
Copy Markdown
Owner

Summary

This is a second test-cleanup pass, after #101. It changes tests only: no production file changes, and no behaviour changes. It splits the test files that grew past 800 lines, many during the #102–#106 compliance work, and fixes three weak tests.

Commit What
registry track_test.go (1047 lines) → track_test.go (513, registry and entry basics) + ledger_test.go (450, the dedup ledger: §2.4.2/§9.1/§12.8/§12.9). Small shared claim helpers replace the repeated closures.
session datastream_object_test.go (1020) → datastream_subgroup_test.go, datastream_subgroup_delta_test.go and datastream_fetch_test.go. sendSubgroup and writeObjects move to helpers_test.go.
relay cross_relay_test.go (1378), session_pubsub_test.go (1076) and handler_fanout_test.go (907) → 8 topic files, each under 400 lines. Shared helpers move into harness_test.go and helpers_test.go, and near-identical tests share one body.
follow-ups helpers_test.go (759) split by role into helpers_data_test.go and helpers_namespace_test.go, and the test fixes below.

Test fixes

  • TestTrackStatus_ReplyForKnownTrack: it published the raw bytes "rtp-h265" as Track Properties. That isn't a valid Key-Value-Pair encoding, and the test only worked because those bytes happen to parse. It now publishes well-formed properties and checks that TRACK_STATUS_OK returns them byte for byte.
  • TestPublish_ForwardedAliasDoesNotCollide: it registered only the first forwarded PUBLISH, so it relied on the colliding rtp PUBLISH arriving first. cam1's PUBLISH is forwarded too (§10.20). The test now registers each forwarded PUBLISH until the rtp one. I checked that it fails when every forwarded alias is forced to collide.
  • TestIncomingFetchStream_ReadDecoded: an End of Range marker is compared by its Location only. Subgroup ID and Priority are not present on a marker (§11.4.4.2), so the test no longer pins the decoder's zero values.
  • Citation: §11 becomes §11.2.1.1 in the invalid-status test.

Test set

  • Same test names: the top-level test names are the same apart from these renames, from table-driving:
    • TestSubgroupObjectWithProperties → TestSubgroupObjectRoundTrip/with_properties
    • TestIncomingFetchStream_ReadDecoded_{Ascending,Descending,EndOfRange} → subtests of TestIncomingFetchStream_ReadDecoded
  • Counts:
    • relay: 332 entries and 457 passes, before and after.
    • registry: 58 and 166, before and after.
    • session subtests: 167 before, 172 after.
  • Stricter in places: some merged cases now assert more than before. For example, TestWriteObjectAtRejectsNonIncreasing now fails if a duplicate or lower ID is accepted, and some relay tests now also check payloads, the FIN or the Track Alias.

Checks

  • Lint, suite, race: 0 lint issues; the full suite and -race pass. The per-package agents also stress-ran the moved tests under -race (15–30 runs).
  • Reviews: moqt-reviewer checked each split commit and the whole branch: no production file changed, no assertion was lost, and the citations are correct.

🤖 Generated with Claude Code

floatdrop and others added 5 commits September 26, 2026 15:35
track_test.go (1047 lines) mixed TrackRegistry/TrackEntry basics with the
§2.1/§2.4.2/§9.1/§12.8/§12.9 dedup ledger. Split it into:

- track_test.go (513): registry and entry basics, cache TTL policy,
  DeleteIfUnused.
- ledger_test.go (450): ClaimDelivered, gap properties, final Objects,
  RecordDuplicate and the late-end cache purge, with small shared helpers
  (newTestEntry, mustClaim, cacheAndClaim) replacing the per-test claim
  closures and cache-then-claim loops.
- helpers_test.go: newTestTrackName moved here, now built on ns().

Comments trimmed to contract/citation/why; every § citation is kept.
Test set unchanged: 58 top-level tests and 166 PASS lines (tests +
subtests) before and after, no renames.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Split the 1020-line datastream_object_test.go into
datastream_subgroup_test.go (subgroup object encode/decode),
datastream_subgroup_delta_test.go (WriteObjectAt / §11.4.2 Object ID
deltas and SubgroupID modes) and datastream_fetch_test.go (fetch
objects and the §11.4.4 decoder).

The open/write/close/accept writer goroutine repeated in every test is
now sendSubgroup + writeObjects in helpers_test.go (used by both
subgroup files) and sendFetch in the fetch file (its only user).
Comments trimmed to contract/citation/why; every § citation is kept.

Table-driven: TestSubgroupObjectWithProperties is now
TestSubgroupObjectRoundTrip/with_properties (plain case:
.../without_properties), and TestIncomingFetchStream_ReadDecoded_
{Ascending,Descending,EndOfRange} are now subtests of
TestIncomingFetchStream_ReadDecoded; the MarkerFirst violation subtests
share one loop under their existing names. Merged cases now assert
every decoded field plus trailing EOF, where some checked a subset.

Test set otherwise unchanged: top-level 248 -> 245 and run names
412 -> 414 (subtests 167 -> 172), the difference being exactly the
renames above.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ts by topic

Split by topic, each file under 600 lines:
- cross_relay_test.go: routing and dialing. New files
  cross_relay_namespace_test.go (Discovery namespace watch) and
  cross_relay_state_test.go (GOAWAY, LARGEST_OBJECT backfill, PUBLISH_DONE).
- session_pubsub_test.go is replaced by session_publish_test.go (inbound and
  forwarded PUBLISH), session_subscribe_test.go and session_upstream_test.go
  (on-demand upstream SUBSCRIBE).
- handler_fanout_test.go: forwarding and filters. New file
  handler_fanout_lifecycle_test.go (stalled or unresponsive subscribers,
  inbound reset). The two TestSubscribe_* tests moved to
  session_subscribe_test.go.

Helpers now shared:
- harness_test.go: testRelay, startTestRelay, dialClient, plus new
  dialerTo, startRelayPair and publishOnRelay.
- helpers_test.go: opaqueProps, objEvent/readSubgroups, readUntilEnd,
  writeSubgroupObjects, publishNS/subscribeNS and the requireNamespace* /
  requireQuiet assertions, all moved from their test files. Also new:
  readNextSubgroup/awaitSubgroupRead and readvertise, which replaces three
  hand-rolled re-advertise tickers.

Near-identical tests now share one body:
- AbsoluteStart/AbsoluteRange filters: requireFilterForwards
- Upstream FORWARD paused/omitted: upstreamForwardFor
- the two PublisherDisappears tests
- the two forwarded-PUBLISH parameter tests: forwardedCam7

Fixed sleeps became waitRelayLargest waits. Comments were trimmed to
contract, citation and reason. Every § citation is kept.

TestTrackStatus_ReplyForKnownTrack published TrackProperties
[]byte("rtp-h265"). That is not a valid Key-Value-Pair encoding and only
passed because the bytes happen to parse. It now publishes real Track
Properties (one unknown, non-mandatory property of type 0x101, via
opaqueProps) and asserts TRACK_STATUS_OK echoes them byte for byte.

Tests only, no production code changed. The test and subtest set is
unchanged: 332 entries from `go test -list` (327 Test + 5 Benchmark) and
457 PASS lines (327 top-level + 130 subtests), before and after.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- relay: helpers_test.go (759 lines) split by role into
  helpers_data_test.go (data-stream readers) and
  helpers_namespace_test.go (namespace and request-stream messages).
- relay: TestPublish_ForwardedAliasDoesNotCollide registers each
  forwarded PUBLISH until the colliding rtp one; it relied on rtp being
  forwarded first, while cam1 may be too (§10.20). Verified: with every
  forwarded alias forced to 1 the test fails either way.
- session: a fetch End of Range marker is compared by its Location only,
  not by Subgroup ID and Priority the draft leaves undefined; and the
  invalid-status test cites §11.2.1.1, not §11.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Review nits: an End of Range marker's Subgroup ID and Priority are not
present (§11.4.4.2), and a SUBSCRIBE_TRACKS holder is sent PUBLISH for
existing tracks too (§10.20). Comment wording only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@floatdrop
floatdrop merged commit 7e2e08e into draft-20 Sep 26, 2026
11 checks passed
@floatdrop
floatdrop deleted the cleanup/tests-2 branch September 26, 2026 11:06
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