diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2020-08-04 18:10:36 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2020-08-05 13:23:21 +0300 |
commit | 33801fe9ba05c4bd304ebd8e40eb1337309f6b48 (patch) | |
tree | b87bdce7099c8f8c11ba9ecfe0ba81470ce38258 /internal/serving | |
parent | b2922c74ae775f4a56c784572c6672fa2c7332fa (diff) |
Fix tests that use illegal ../ paths
Diffstat (limited to 'internal/serving')
-rw-r--r-- | internal/serving/disk/serving_test.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/internal/serving/disk/serving_test.go b/internal/serving/disk/serving_test.go index 6398700d..02b7fac7 100644 --- a/internal/serving/disk/serving_test.go +++ b/internal/serving/disk/serving_test.go @@ -9,9 +9,12 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-pages/internal/serving" + "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers" ) func TestDisk_ServeFileHTTP(t *testing.T) { + defer setUpTests(t)() + s := New() w := httptest.NewRecorder() r := httptest.NewRequest("GET", "http://group.gitlab-example.com/serving/index.html", nil) @@ -20,7 +23,7 @@ func TestDisk_ServeFileHTTP(t *testing.T) { Request: r, LookupPath: &serving.LookupPath{ Prefix: "/serving", - Path: "../../../shared/pages/group/serving/public", + Path: "group/serving/public", }, SubPath: "/index.html", } @@ -36,3 +39,10 @@ func TestDisk_ServeFileHTTP(t *testing.T) { require.Contains(t, string(body), "HTML Document") } + +var chdirSet = false + +func setUpTests(t testing.TB) func() { + t.Helper() + return testhelpers.ChdirInPath(t, "../../../shared/pages", &chdirSet) +} |