MCPcopy
hub / github.com/grpc/grpc-go / TestEndpointMap_Delete

Method TestEndpointMap_Delete

resolver/map_test.go:265–293  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

263}
264
265func (s) TestEndpointMap_Delete(t *testing.T) {
266 em := NewEndpointMap[struct{}]()
267 // Initial state of system: [1, 2, 3, 12]
268 em.Set(endpoint1, struct{}{})
269 em.Set(endpoint2, struct{}{})
270 em.Set(endpoint3, struct{}{})
271 em.Set(endpoint12, struct{}{})
272 // Delete: [2, 21]
273 em.Delete(endpoint2)
274 em.Delete(endpoint21)
275
276 // [1, 3] should be present:
277 if _, ok := em.Get(endpoint1); !ok {
278 t.Fatalf("em.Get(endpoint1) = %v, want true", ok)
279 }
280 if _, ok := em.Get(endpoint3); !ok {
281 t.Fatalf("em.Get(endpoint3) = %v, want true", ok)
282 }
283 // [2, 12] should not be present:
284 if _, ok := em.Get(endpoint2); ok {
285 t.Fatalf("em.Get(endpoint2) = %v, want false", ok)
286 }
287 if _, ok := em.Get(endpoint12); ok {
288 t.Fatalf("em.Get(endpoint12) = %v, want false", ok)
289 }
290 if _, ok := em.Get(endpoint21); ok {
291 t.Fatalf("em.Get(endpoint21) = %v, want false", ok)
292 }
293}
294
295func (s) TestEndpointMap_Values(t *testing.T) {
296 em := NewEndpointMap[int]()

Callers

nothing calls this directly

Calls 5

NewEndpointMapFunction · 0.85
SetMethod · 0.65
GetMethod · 0.65
FatalfMethod · 0.65
DeleteMethod · 0.45

Tested by

no test coverage detected