(t *testing.T)
| 41 | } |
| 42 | |
| 43 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…