diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-09-09 09:23:02 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-09-24 03:22:45 +0300 |
commit | 3e20c84456ec3194de8a35af3cd287a37c006549 (patch) | |
tree | 537e905021f4803bbb67c570136a0c0895ed1424 /helpers_test.go | |
parent | 7802bb75e8edafe05855fcbdb72aeea7bb906ae7 (diff) |
Rebase from base branch
Add vfs.VFS implementation for zip
Fix build errors
Clean zip vfs
Add tests for Root
Add zip serving metric
Return a zip.Instance() when source == zip
Add simple acceptance test for zip serving
Use correct contents
No need to start testServer in go routine
Diffstat (limited to 'helpers_test.go')
-rw-r--r-- | helpers_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/helpers_test.go b/helpers_test.go index d08869fd..6ee11b86 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -522,3 +522,31 @@ func copyFile(dest, src string) error { _, err = io.Copy(destFile, srcFile) return err } + +func newZipFileServerURL(t *testing.T, zipFilePath string) (string, func()) { + t.Helper() + + m := http.NewServeMux() + m.HandleFunc("/public.zip", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, zipFilePath) + })) + + // create a listener with the desired port. + l, err := net.Listen("tcp", objectStorageMockServer) + require.NoError(t, err) + + testServer := httptest.NewUnstartedServer(m) + + // NewUnstartedServer creates a listener. Close that listener and replace + // with the one we created. + testServer.Listener.Close() + testServer.Listener = l + + // Start the server. + testServer.Start() + + return testServer.URL, func() { + // Cleanup. + testServer.Close() + } +} |