diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-12-04 12:56:15 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-12-04 12:58:22 +0300 |
commit | 061955ee870d483751cd8cef42e6bd694d98d033 (patch) | |
tree | d9761c505628f16b1d572637efe10e09023b50dc /helpers_test.go | |
parent | c8ce9b3637df9a5493d4febce1b23b1112a0db3c (diff) |
Handle non-existent domains properly using 204 status
Diffstat (limited to 'helpers_test.go')
-rw-r--r-- | helpers_test.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/helpers_test.go b/helpers_test.go index b13fb18f..fc903404 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -385,8 +385,16 @@ func waitForRoundtrips(t *testing.T, listeners []ListenSpec, timeout time.Durati func NewGitlabDomainsSourceStub(t *testing.T) *httptest.Server { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { domain := r.URL.Query().Get("host") + path := "shared/lookups/" + domain + ".json" - fixture, err := os.Open("shared/lookups/" + domain + ".json") + if _, err := os.Stat(path); os.IsNotExist(err) { + w.WriteHeader(http.StatusNoContent) + + t.Logf("GitLab domain %s source stub served 204", domain) + return + } + + fixture, err := os.Open(path) defer fixture.Close() require.NoError(t, err) |