MCPcopy Create free account
hub / github.com/easyp-tech/server / TestProbeCommitID_HitResolvesAndCaches

Function TestProbeCommitID_HitResolvesAndCaches

internal/connect/api_test.go:1390–1410  ·  view source on GitHub ↗

TestProbeCommitID_HitResolvesAndCaches verifies that a sha owned by exactly one source is resolved by the probe and registered as an alias so later requests for it hit the commit map directly.

(t *testing.T)

Source from the content-addressed store, hash-verified

1388// one source is resolved by the probe and registered as an alias so later
1389// requests for it hit the commit map directly.
1390func TestProbeCommitID_HitResolvesAndCaches(t *testing.T) {
1391 var calls atomic.Int32
1392 repo := &mockProvider{repos: []source.Source{
1393 &mockSource{owner: "cyp", repoName: "cyp-apis", commit: "deadbeef", getMetaCalls: &calls},
1394 &mockSource{owner: "googleapis", repoName: "googleapis", commit: "cafef00d", getMetaCalls: &calls},
1395 }}
1396 h := newTestCommitHandler(repo)
1397 h.probeEnabled = true
1398
1399 ref, ok := h.probeCommitID(context.Background(), "deadbeef")
1400 if !ok || ref == nil || ref.owner != "cyp" || ref.module != "cyp-apis" {
1401 t.Fatalf("probe should resolve deadbeef -> cyp/cyp-apis; ok=%v ref=%+v", ok, ref)
1402 }
1403
1404 h.commitMu.RLock()
1405 _, present := h.commitMap["deadbeef"]
1406 h.commitMu.RUnlock()
1407 if !present {
1408 t.Error("probe hit did not register deadbeef as a commitMap alias")
1409 }
1410}
1411
1412// TestProbeCommitID_MissNegativeCaches verifies a bogus sha is reported as a
1413// miss, recorded in the negative cache, and that a retry within TTL does NOT

Callers

nothing calls this directly

Calls 3

newTestCommitHandlerFunction · 0.85
probeCommitIDMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected