MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestClaim_DifferentUsersIsolated

Function TestClaim_DifferentUsersIsolated

internal/idempotency/store_test.go:148–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestClaim_DifferentUsersIsolated(t *testing.T) {
149 pool := testutil.TestDB(t)
150 identStore := identity.NewStore(pool)
151 idemStore := idempotency.NewStore(pool)
152 ctx := context.Background()
153
154 uA, _ := identStore.CreateOrGetUser(ctx, "user-a@example.com", "A", "google-a")
155 uB, _ := identStore.CreateOrGetUser(ctx, "user-b@example.com", "B", "google-b")
156
157 hash := idempotency.HashBody([]byte(`{"x":1}`))
158
159 a, _ := idemStore.Claim(ctx, uA.ID, "shared", "/api/v1/send", hash)
160 if a.Outcome != idempotency.OutcomeAcquired {
161 t.Fatalf("A Outcome = %d", a.Outcome)
162 }
163 // Same key, different user — must not collide.
164 b, _ := idemStore.Claim(ctx, uB.ID, "shared", "/api/v1/send", hash)
165 if b.Outcome != idempotency.OutcomeAcquired {
166 t.Errorf("B Outcome = %d, want OutcomeAcquired (different user)", b.Outcome)
167 }
168}
169
170func TestRelease_AllowsFreshClaim(t *testing.T) {
171 store, userID, _ := newStoreAndUser(t)

Callers

nothing calls this directly

Calls 6

CreateOrGetUserMethod · 0.95
ClaimMethod · 0.95
TestDBFunction · 0.92
NewStoreFunction · 0.92
NewStoreFunction · 0.92
HashBodyFunction · 0.92

Tested by

no test coverage detected