diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2022-06-04 16:57:57 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2022-06-04 16:57:57 +0100 |
| commit | b52c712770dbc9b0b0adb8a106427fa59a9de7f8 (patch) | |
| tree | c8f36864e70eae2c1fa775429ab4cf953b833aa9 /resp_test.go | |
| parent | d90994408fed47a8fb7a2d82e2f751d8da7067e4 (diff) | |
Return 404 when the package name does not match
Diffstat (limited to 'resp_test.go')
| -rw-r--r-- | resp_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/resp_test.go b/resp_test.go index 1f8c458..7e01946 100644 --- a/resp_test.go +++ b/resp_test.go @@ -14,6 +14,17 @@ import ( func TestRedirector_ServeHTTP(t *testing.T) { r := &redirector{regexp.MustCompile(`src\.example\.com/x`), "https://example.com/git", "git"} + t.Run("NotFound", func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "https://example.com/foo", nil) + w := httptest.NewRecorder() + r.ServeHTTP(w, req) + + resp := w.Result() + if http.StatusNotFound != resp.StatusCode { + t.Errorf("expected %d, got %d", http.StatusNotFound, resp.StatusCode) + } + }) + t.Run("GoVisit", func(t *testing.T) { req := httptest.NewRequest(http.MethodGet, "https://src.example.com/x/foo?go-get=1", nil) w := httptest.NewRecorder() |
