MCPcopy Create free account
hub / github.com/cortexproject/cortex / Test_extractHeader

Function Test_extractHeader

pkg/ruler/frontend_client_test.go:311–345  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

309}
310
311func Test_extractHeader(t *testing.T) {
312 tests := []struct {
313 description string
314 headers []*httpgrpc.Header
315 expectedOutput string
316 }{
317 {
318 description: "cortex query proto",
319 headers: []*httpgrpc.Header{
320 {
321 Key: "Content-Type",
322 Values: []string{"application/x-cortex-query+proto"},
323 },
324 },
325 expectedOutput: "application/x-cortex-query+proto",
326 },
327 {
328 description: "json",
329 headers: []*httpgrpc.Header{
330 {
331 Key: "Content-Type",
332 Values: []string{"application/json"},
333 },
334 },
335 expectedOutput: "application/json",
336 },
337 }
338
339 target := "Content-Type"
340 for _, test := range tests {
341 t.Run(test.description, func(t *testing.T) {
342 require.Equal(t, test.expectedOutput, extractHeader(test.headers, target))
343 })
344 }
345}

Callers

nothing calls this directly

Calls 3

extractHeaderFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected