MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestMetadata

Function TestMetadata

pkg/webmiddleware/metadata_test.go:28–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestMetadata(t *testing.T) {
29 a := assertions.New(t)
30
31 m := Metadata("authorization", "X-Request-Id")
32
33 r := httptest.NewRequest(http.MethodGet, "/", nil)
34 r.Header.Set("Authorization", "Bearer token")
35 r.Header.Set("X-Request-Id", "XXX")
36
37 rec := httptest.NewRecorder()
38 m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
39 md, _ := metadata.FromIncomingContext(r.Context())
40 a.So(md.Get("authorization"), should.Resemble, []string{"Bearer token"})
41 a.So(md.Get("x-request-id"), should.Resemble, []string{"XXX"})
42 })).ServeHTTP(rec, r)
43}

Callers

nothing calls this directly

Calls 6

MetadataFunction · 0.85
NewMethod · 0.65
SetMethod · 0.65
ContextMethod · 0.65
GetMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected