(t *testing.T)
| 1530 | } |
| 1531 | |
| 1532 | func TestMuxMissingParams(t *testing.T) { |
| 1533 | r := NewRouter() |
| 1534 | r.Get(`/user/{userId:\d+}`, func(w http.ResponseWriter, r *http.Request) { |
| 1535 | userID := URLParam(r, "userId") |
| 1536 | w.Write([]byte(fmt.Sprintf("userId = '%s'", userID))) |
| 1537 | }) |
| 1538 | r.NotFound(func(w http.ResponseWriter, r *http.Request) { |
| 1539 | w.WriteHeader(404) |
| 1540 | w.Write([]byte("nothing here")) |
| 1541 | }) |
| 1542 | |
| 1543 | ts := httptest.NewServer(r) |
| 1544 | defer ts.Close() |
| 1545 | |
| 1546 | if _, body := testRequest(t, ts, "GET", "/user/123", nil); body != "userId = '123'" { |
| 1547 | t.Fatal(body) |
| 1548 | } |
| 1549 | if _, body := testRequest(t, ts, "GET", "/user/", nil); body != "nothing here" { |
| 1550 | t.Fatal(body) |
| 1551 | } |
| 1552 | } |
| 1553 | |
| 1554 | func TestMuxWildcardRoute(t *testing.T) { |
| 1555 | handler := func(w http.ResponseWriter, r *http.Request) {} |
nothing calls this directly
no test coverage detected