diff options
author | Krasimir Angelov <kangelov@gitlab.com> | 2019-12-16 04:02:47 +0300 |
---|---|---|
committer | Krasimir Angelov <kangelov@gitlab.com> | 2019-12-16 04:02:47 +0300 |
commit | b2c4c0d8081fd6aab4081cc9d0cbcdcc486a43a8 (patch) | |
tree | 8a7bc7d4f160583125df9e82ccc694513b3a7f94 | |
parent | 2982fb3784ad440226904fb5e4e54ef0a57de49b (diff) |
-rw-r--r-- | acceptance_test.go | 8 | ||||
-rw-r--r-- | helpers_test.go | 21 |
2 files changed, 23 insertions, 6 deletions
diff --git a/acceptance_test.go b/acceptance_test.go index dac3776a..1cc231fc 100644 --- a/acceptance_test.go +++ b/acceptance_test.go @@ -1534,15 +1534,19 @@ func TestTLSVersions(t *testing.T) { } func TestGitlabDomainsSource(t *testing.T) { - skipUnlessEnabled(t, "not-daemonized") + skipUnlessEnabled(t) source := NewGitlabDomainsSourceStub(t) defer source.Close() - newSourceDomainsFile := CreateNewSourceDomainsFixtureFile(t, "new-source-test.gitlab.io\nnon-existent-domain.gitlab.io") + newSourceDomainsFile, cleanupNewSourceDomainsFile := CreateNewSourceDomainsFixtureFile(t, "new-source-test.gitlab.io\nnon-existent-domain.gitlab.io") newSourceDomainsFile = "GITLAB_NEW_SOURCE_DOMAINS_FILE=" + newSourceDomainsFile + defer cleanupNewSourceDomainsFile() + gitLabAPISecretKey := CreateGitLabAPISecretKeyFixtureFile(t) + pagesArgs := []string{"-gitlab-server", source.URL, "-api-secret-key", gitLabAPISecretKey} + teardown := RunPagesProcessWithEnvs(t, true, *pagesBinary, listeners, "", []string{newSourceDomainsFile}, pagesArgs...) defer teardown() diff --git a/helpers_test.go b/helpers_test.go index 8bb3b65d..64e2606e 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -12,6 +12,7 @@ import ( "net/http/httptest" "os" "os/exec" + "path/filepath" "strings" "testing" "time" @@ -85,14 +86,26 @@ func CreateGitLabAPISecretKeyFixtureFile(t *testing.T) (filepath string) { return secretfile.Name() } -func CreateNewSourceDomainsFixtureFile(t *testing.T, domains string) (filepath string) { - domainsfile, err := ioutil.TempFile("", "new-source-domains") +func CreateNewSourceDomainsFixtureFile(t *testing.T, domains string) (filename string, cleanup func()) { + daemonized := os.Getenv("TEST_DAEMONIZE") != "" + + dir := "" + if daemonized { + dir = "shared/pages" + } + domainsfile, err := ioutil.TempFile(dir, "new-source-domains") require.NoError(t, err) - domainsfile.Close() + cleanup = func() { domainsfile.Close() } + cleanup() require.NoError(t, ioutil.WriteFile(domainsfile.Name(), []byte(domains), 0644)) - return domainsfile.Name() + filename = domainsfile.Name() + if daemonized { + filename = filepath.Base(filename) + } + + return filename, cleanup } // ListenSpec is used to point at a gitlab-pages http server, preserving the |