(t *testing.T)
| 234 | } |
| 235 | |
| 236 | func (s) TestValueFromIncomingContext(t *testing.T) { |
| 237 | md := Pairs( |
| 238 | "X-My-Header-1", "42", |
| 239 | "X-My-Header-2", "43-1", |
| 240 | "X-My-Header-2", "43-2", |
| 241 | "x-my-header-3", "44", |
| 242 | ) |
| 243 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 244 | defer cancel() |
| 245 | // Verify that we lowercase if callers directly modify md |
| 246 | md["X-INCORRECT-UPPERCASE"] = []string{"foo"} |
| 247 | ctx = NewIncomingContext(ctx, md) |
| 248 | |
| 249 | for _, test := range []struct { |
| 250 | key string |
| 251 | want []string |
| 252 | }{ |
| 253 | { |
| 254 | key: "x-my-header-1", |
| 255 | want: []string{"42"}, |
| 256 | }, |
| 257 | { |
| 258 | key: "x-my-header-2", |
| 259 | want: []string{"43-1", "43-2"}, |
| 260 | }, |
| 261 | { |
| 262 | key: "x-my-header-3", |
| 263 | want: []string{"44"}, |
| 264 | }, |
| 265 | { |
| 266 | key: "x-unknown", |
| 267 | want: nil, |
| 268 | }, |
| 269 | { |
| 270 | key: "x-incorrect-uppercase", |
| 271 | want: []string{"foo"}, |
| 272 | }, |
| 273 | } { |
| 274 | v := ValueFromIncomingContext(ctx, test.key) |
| 275 | if !reflect.DeepEqual(v, test.want) { |
| 276 | t.Errorf("value of metadata is %v, want %v", v, test.want) |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | func (s) TestAppendToOutgoingContext(t *testing.T) { |
| 282 | // Pre-existing metadata |
nothing calls this directly
no test coverage detected