(t *testing.T, title string, f Flags, expectedStatus int)
| 11 | ) |
| 12 | |
| 13 | func testPatch(t *testing.T, title string, f Flags, expectedStatus int) { |
| 14 | t.Run(title, func(t *testing.T) { |
| 15 | dc, err := routestring.New(`Path("/foo%2Fbar") -> status(200) -> <shunt>`) |
| 16 | if err != nil { |
| 17 | t.Fatal(err) |
| 18 | } |
| 19 | |
| 20 | rt := routing.New(routing.Options{ |
| 21 | SignalFirstLoad: true, |
| 22 | FilterRegistry: builtin.MakeRegistry(), |
| 23 | DataClients: []routing.DataClient{dc}, |
| 24 | }) |
| 25 | defer rt.Close() |
| 26 | |
| 27 | p := WithParams(Params{Routing: rt, Flags: f}) |
| 28 | defer p.Close() |
| 29 | |
| 30 | s := httptest.NewServer(p) |
| 31 | defer s.Close() |
| 32 | |
| 33 | <-rt.FirstLoad() |
| 34 | |
| 35 | rsp, err := http.Get(s.URL + "/foo%2Fbar") |
| 36 | if err != nil { |
| 37 | t.Fatal(err) |
| 38 | } |
| 39 | |
| 40 | defer rsp.Body.Close() |
| 41 | |
| 42 | if rsp.StatusCode != expectedStatus { |
| 43 | t.Error() |
| 44 | } |
| 45 | }) |
| 46 | } |
| 47 | |
| 48 | func TestPathPatch(t *testing.T) { |
| 49 | testPatch(t, "not patched", FlagsNone, http.StatusNotFound) |
no test coverage detected
searching dependent graphs…