diff --git a/fs/operations/rc_test.go b/fs/operations/rc_test.go index 98e383270..d0684215f 100644 --- a/fs/operations/rc_test.go +++ b/fs/operations/rc_test.go @@ -544,7 +544,7 @@ func TestUploadFile(t *testing.T) { r, call := rcNewRun(t, "operations/uploadfile") ctx := context.Background() - testFileName := "test.txt" + testFileName := "uploadfile-test.txt" testFileContent := "Hello World" r.WriteFile(testFileName, testFileContent, t1) testItem1 := fstest.NewItem(testFileName, testFileContent, t1) @@ -553,6 +553,10 @@ func TestUploadFile(t *testing.T) { currentFile, err := os.Open(path.Join(r.LocalName, testFileName)) require.NoError(t, err) + defer func() { + assert.NoError(t, currentFile.Close()) + }() + formReader, contentType, _, err := rest.MultipartUpload(ctx, currentFile, url.Values{}, "file", testFileName) require.NoError(t, err) @@ -572,10 +576,14 @@ func TestUploadFile(t *testing.T) { assert.NoError(t, r.Fremote.Mkdir(context.Background(), "subdir")) - currentFile, err = os.Open(path.Join(r.LocalName, testFileName)) + currentFile2, err := os.Open(path.Join(r.LocalName, testFileName)) require.NoError(t, err) - formReader, contentType, _, err = rest.MultipartUpload(ctx, currentFile, url.Values{}, "file", testFileName) + defer func() { + assert.NoError(t, currentFile2.Close()) + }() + + formReader, contentType, _, err = rest.MultipartUpload(ctx, currentFile2, url.Values{}, "file", testFileName) require.NoError(t, err) httpReq = httptest.NewRequest("POST", "/", formReader)