diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-02-03 09:06:02 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-02-15 02:17:24 +0300 |
commit | 586317c827f5878444bcc86bf953b21e7e31ee10 (patch) | |
tree | b24d2dbd5ccb4c72acb670f5464ec190c83c12c1 /internal/testhelpers | |
parent | 24cc61d186feaefec3cc08225c58b07d3767dbbb (diff) |
Add extra tests for serving zip archives from disk
Diffstat (limited to 'internal/testhelpers')
-rw-r--r-- | internal/testhelpers/testhelpers.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/testhelpers/testhelpers.go b/internal/testhelpers/testhelpers.go index 422a3d9a..f731166b 100644 --- a/internal/testhelpers/testhelpers.go +++ b/internal/testhelpers/testhelpers.go @@ -1,10 +1,12 @@ package testhelpers import ( + "fmt" "mime" "net/http" "net/http/httptest" "net/url" + "os" "testing" "github.com/sirupsen/logrus" @@ -55,3 +57,14 @@ func AssertLogContains(t *testing.T, wantLogEntry string, entries []*logrus.Entr require.Contains(t, messages, wantLogEntry) } } + +// ToFileProtocol appends the file:// protocol to the current os.Getwd +// and formats path to be a full filepath +func ToFileProtocol(t *testing.T, path string) string { + t.Helper() + + wd, err := os.Getwd() + require.NoError(t, err) + + return fmt.Sprintf("file://%s/%s", wd, path) +} |