Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-12-04 12:56:15 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-12-04 12:58:22 +0300
commit061955ee870d483751cd8cef42e6bd694d98d033 (patch)
treed9761c505628f16b1d572637efe10e09023b50dc /helpers_test.go
parentc8ce9b3637df9a5493d4febce1b23b1112a0db3c (diff)
Handle non-existent domains properly using 204 status
Diffstat (limited to 'helpers_test.go')
-rw-r--r--helpers_test.go10
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)