MCPcopy
hub / github.com/prometheus/pushgateway / TestRoutePrefixForStatic

Function TestRoutePrefixForStatic

handler/misc_test.go:43–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestRoutePrefixForStatic(t *testing.T) {
44 fs := &fakeFileSystem{map[string]struct{}{
45 "/index.js": struct{}{},
46 }}
47
48 for _, test := range []struct {
49 prefix string
50 path string
51 code int
52 }{
53 {"/", "/index.js", 200},
54 {"/", "/missing.js", 404},
55 {"/route-prefix", "/index.js", 200},
56 {"/route-prefix", "/missing.js", 404},
57 } {
58 t.Run(fmt.Sprintf("%v", test), func(t *testing.T) {
59 t.Parallel()
60 req, err := http.NewRequest(
61 http.MethodGet, "http://example.com"+test.prefix+test.path, nil,
62 )
63 if err != nil {
64 t.Fatal(err)
65 }
66 w := httptest.NewRecorder()
67 static := Static(fs, test.prefix)
68 static.ServeHTTP(w, req)
69 if test.code != w.Code {
70 t.Errorf("Wanted %d, got %d.", test.code, w.Code)
71 }
72 })
73 }
74}

Callers

nothing calls this directly

Calls 1

StaticFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…