Repository navigation
test(mcp): pin dedupe merge semantics with focused tests - #380
Conversation
Covers the eight behaviours from Podiom#378: non-nil empty results for nil/empty input, the untrimmed empty-name guard, bytewise case-sensitive ordering, URL-into-stdio merging, per-field first-wins, the invented podiom source, Args aliasing on first insert only, and the nil-EnvVars / non-nil-EnvStatus shape. The LookupEnv case is deterministic via t.Setenv plus a skipped-if-present unset sentinel. dedupe: 44.4% -> 97.2%; envStatus and mergeSources reach 100%. Tests only; no production code touched.
|
Nice set — I ran these against mutated copies of
Everything else is clean here — build, full |
|
Ran these against the real function: I broke One assertion doesn't bite. In got2 := dedupe([]Server{
{Name: "y", Args: []string{"a"}},
{Name: "y", Args: in2},
})The first entry already has Dropping {Name: "y"},With that, the same mutation fails the test. Push it and I'll merge. |
|
My second comment only named the Args gap — there are two, and I should have repeated both. The other is Both are one-liners. Push them together and it goes in. |
TestDedupeFirstWinsPerField: the first entry had no URL, so last-wins passed too. Give it one and pin that the second does not replace it. URL backfill stays covered by TestDedupeMergesURLIntoStdio. TestDedupeAliasesCallerArgsOnFirstInsert: the first entry had Args, so len(existing.Args) == 0 was false and the merge-path copy never ran. Drop them to reach the branch. Co-Authored-By: Claude <[email protected]>
|
Merged. I pushed the two one-liners myself rather than leave this sitting — the Args change drops Both bite now: last-wins on Your eleven tests are the substance here. If Podiom is useful to you, a star helps. |
Adds
internal/mcp/dedupe_test.gowith focused tests fordedupeand the helpers it calls, per #378.Covered behaviours (each trace verified against
masterbefore writing the tests):dedupe(nil)anddedupe([]Server{})return a non-nil empty slice.s.Name == ""with no trim: whitespace-only names survive, and"x "/"x"stay separate. Ordering is case-sensitive bytewise (A, X, a, b, x).stdiobefore it is stored, so theif existing.Transport == ""guard in the merge block never fires and the URL is backfilled without a transport fix.{Command:"first", Sources:[codex]}+{Command:"second", URL:"https://u", Sources:[podiom]}yieldsCommand:"first"withURL:"https://u"and sources[podiom codex].podiomsource is added only when the first occurrence has none; output order is always podiom -> claude -> codex regardless of input order.Argson first insert (the duplicate path copies).EnvVars == nilwhileEnvStatusis a non-nil empty slice.envStatuscallsos.LookupEnv, so the set case runs undert.Setenvand the unset case uses a sentinel name that skips the test if it is unexpectedly present.Verification:
Tests only — no production behavior change.
Closes #378.