Test cleanup: split oversized test files, fix three weak tests (tests only) - #107
Merged
Merged
Conversation
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>
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
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.
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.datastream_object_test.go(1020) →datastream_subgroup_test.go,datastream_subgroup_delta_test.goanddatastream_fetch_test.go.sendSubgroupandwriteObjectsmove tohelpers_test.go.cross_relay_test.go(1378),session_pubsub_test.go(1076) andhandler_fanout_test.go(907) → 8 topic files, each under 400 lines. Shared helpers move intoharness_test.goandhelpers_test.go, and near-identical tests share one body.helpers_test.go(759) split by role intohelpers_data_test.goandhelpers_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 collidingrtpPUBLISH arriving first. cam1's PUBLISH is forwarded too (§10.20). The test now registers each forwarded PUBLISH until thertpone. 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.Test set
TestSubgroupObjectWithProperties→TestSubgroupObjectRoundTrip/with_propertiesTestIncomingFetchStream_ReadDecoded_{Ascending,Descending,EndOfRange}→ subtests ofTestIncomingFetchStream_ReadDecodedTestWriteObjectAtRejectsNonIncreasingnow fails if a duplicate or lower ID is accepted, and some relay tests now also check payloads, the FIN or the Track Alias.Checks
-racepass. The per-package agents also stress-ran the moved tests under-race(15–30 runs).🤖 Generated with Claude Code