(t *testing.T)
| 279 | } |
| 280 | |
| 281 | func (s) TestAppendToOutgoingContext(t *testing.T) { |
| 282 | // Pre-existing metadata |
| 283 | tCtx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 284 | defer cancel() |
| 285 | ctx := NewOutgoingContext(tCtx, Pairs("k1", "v1", "k2", "v2")) |
| 286 | ctx = AppendToOutgoingContext(ctx, "k1", "v3") |
| 287 | ctx = AppendToOutgoingContext(ctx, "k1", "v4") |
| 288 | md, ok := FromOutgoingContext(ctx) |
| 289 | if !ok { |
| 290 | t.Errorf("Expected MD to exist in ctx, but got none") |
| 291 | } |
| 292 | want := Pairs("k1", "v1", "k1", "v3", "k1", "v4", "k2", "v2") |
| 293 | if !reflect.DeepEqual(md, want) { |
| 294 | t.Errorf("context's metadata is %v, want %v", md, want) |
| 295 | } |
| 296 | |
| 297 | // No existing metadata |
| 298 | ctx = AppendToOutgoingContext(tCtx, "k1", "v1") |
| 299 | md, ok = FromOutgoingContext(ctx) |
| 300 | if !ok { |
| 301 | t.Errorf("Expected MD to exist in ctx, but got none") |
| 302 | } |
| 303 | want = Pairs("k1", "v1") |
| 304 | if !reflect.DeepEqual(md, want) { |
| 305 | t.Errorf("context's metadata is %v, want %v", md, want) |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | func (s) TestAppendToOutgoingContext_Repeated(t *testing.T) { |
| 310 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
nothing calls this directly
no test coverage detected