mirror of
https://github.com/rclone/rclone.git
synced 2024-12-22 23:22:08 +01:00
operations: close file in TestUploadFile test so it can be deleted on Windows
This commit is contained in:
parent
bebd82c586
commit
a7978cea56
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user