(t *testing.T)
| 1719 | } |
| 1720 | |
| 1721 | func TestEscapedURLParams(t *testing.T) { |
| 1722 | m := NewRouter() |
| 1723 | m.Get("/api/{identifier}/{region}/{size}/{rotation}/*", func(w http.ResponseWriter, r *http.Request) { |
| 1724 | w.WriteHeader(200) |
| 1725 | rctx := RouteContext(r.Context()) |
| 1726 | if rctx == nil { |
| 1727 | t.Error("no context") |
| 1728 | return |
| 1729 | } |
| 1730 | identifier := URLParam(r, "identifier") |
| 1731 | if identifier != "http:%2f%2fexample.com%2fimage.png" { |
| 1732 | t.Errorf("identifier path parameter incorrect %s", identifier) |
| 1733 | return |
| 1734 | } |
| 1735 | region := URLParam(r, "region") |
| 1736 | if region != "full" { |
| 1737 | t.Errorf("region path parameter incorrect %s", region) |
| 1738 | return |
| 1739 | } |
| 1740 | size := URLParam(r, "size") |
| 1741 | if size != "max" { |
| 1742 | t.Errorf("size path parameter incorrect %s", size) |
| 1743 | return |
| 1744 | } |
| 1745 | rotation := URLParam(r, "rotation") |
| 1746 | if rotation != "0" { |
| 1747 | t.Errorf("rotation path parameter incorrect %s", rotation) |
| 1748 | return |
| 1749 | } |
| 1750 | w.Write([]byte("success")) |
| 1751 | }) |
| 1752 | |
| 1753 | ts := httptest.NewServer(m) |
| 1754 | defer ts.Close() |
| 1755 | |
| 1756 | if _, body := testRequest(t, ts, "GET", "/api/http:%2f%2fexample.com%2fimage.png/full/max/0/color.png", nil); body != "success" { |
| 1757 | t.Fatal(body) |
| 1758 | } |
| 1759 | } |
| 1760 | |
| 1761 | func TestCustomHTTPMethod(t *testing.T) { |
| 1762 | // first we must register this method to be accepted, then we |
nothing calls this directly
no test coverage detected