diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /workhorse/internal/upload/artifacts_store_test.go | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'workhorse/internal/upload/artifacts_store_test.go')
-rw-r--r-- | workhorse/internal/upload/artifacts_store_test.go | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/workhorse/internal/upload/artifacts_store_test.go b/workhorse/internal/upload/artifacts_store_test.go index 97e66fc37a4..7032313fbde 100644 --- a/workhorse/internal/upload/artifacts_store_test.go +++ b/workhorse/internal/upload/artifacts_store_test.go @@ -6,7 +6,7 @@ import ( "crypto/md5" "encoding/hex" "fmt" - "io/ioutil" + "io" "mime/multipart" "net/http" "net/http/httptest" @@ -56,16 +56,11 @@ func testUploadArtifactsFromTestZip(t *testing.T, ts *httptest.Server) *httptest } func TestUploadHandlerSendingToExternalStorage(t *testing.T) { - tempPath, err := ioutil.TempDir("", "uploads") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tempPath) + tempPath := t.TempDir() archiveData, md5 := createTestZipArchive(t) - archiveFile, err := ioutil.TempFile("", "artifact.zip") + archiveFile, err := os.CreateTemp(tempPath, "artifact.zip") require.NoError(t, err) - defer os.Remove(archiveFile.Name()) _, err = archiveFile.Write(archiveData) require.NoError(t, err) archiveFile.Close() @@ -75,7 +70,7 @@ func TestUploadHandlerSendingToExternalStorage(t *testing.T) { storeServerMux.HandleFunc("/url/put", func(w http.ResponseWriter, r *http.Request) { require.Equal(t, "PUT", r.Method) - receivedData, err := ioutil.ReadAll(r.Body) + receivedData, err := io.ReadAll(r.Body) require.NoError(t, err) require.Equal(t, archiveData, receivedData) @@ -135,11 +130,7 @@ func TestUploadHandlerSendingToExternalStorage(t *testing.T) { } func TestUploadHandlerSendingToExternalStorageAndStorageServerUnreachable(t *testing.T) { - tempPath, err := ioutil.TempDir("", "uploads") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tempPath) + tempPath := t.TempDir() responseProcessor := func(w http.ResponseWriter, r *http.Request) { t.Fatal("it should not be called") @@ -161,11 +152,7 @@ func TestUploadHandlerSendingToExternalStorageAndStorageServerUnreachable(t *tes } func TestUploadHandlerSendingToExternalStorageAndInvalidURLIsUsed(t *testing.T) { - tempPath, err := ioutil.TempDir("", "uploads") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tempPath) + tempPath := t.TempDir() responseProcessor := func(w http.ResponseWriter, r *http.Request) { t.Fatal("it should not be called") |