Skip to content

Commit

Permalink
Replace os.OpenFile with os.Create in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramikg authored and sfc-gh-pfus committed Aug 2, 2023
1 parent 98df002 commit f556352
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions encrypt_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestEncryptDecryptFile(t *testing.T) {
data := "test data"
inputFile := "test_encrypt_decrypt_file"

fd, err := os.OpenFile(inputFile, os.O_CREATE|os.O_WRONLY, readWriteFileMode)
fd, err := os.Create(inputFile)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func generateKLinesOfNByteRows(numLines int, numBytes int, tmpDir string) (strin
}
}
fname := path.Join(tmpDir, "file"+strconv.FormatInt(int64(numLines*numBytes), 10))
f, err := os.OpenFile(fname, os.O_CREATE|os.O_WRONLY, readWriteFileMode)
f, err := os.Create(fname)
if err != nil {
return "", err
}
Expand All @@ -191,7 +191,7 @@ func generateKLinesOfNFiles(k int, n int, compress bool, tmpDir string) (string,
}
for i := 0; i < n; i++ {
fname := path.Join(tmpDir, "file"+strconv.FormatInt(int64(i), 10))
f, err := os.OpenFile(fname, os.O_CREATE|os.O_WRONLY, readWriteFileMode)
f, err := os.Create(fname)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -233,7 +233,7 @@ func generateKLinesOfNFiles(k int, n int, compress bool, tmpDir string) (string,
io.ReadAll(gzipErr)
gzipCmd.Wait()
} else {
fOut, err := os.OpenFile(fname+".gz", os.O_CREATE|os.O_WRONLY, readWriteFileMode)
fOut, err := os.Create(fname + ".gz")
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion file_transfer_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestUnitDownloadWithInvalidLocalPath(t *testing.T) {
}
defer os.RemoveAll(tmpDir)
testData := filepath.Join(tmpDir, "data.txt")
f, err := os.OpenFile(testData, os.O_CREATE|os.O_RDWR, readWriteFileMode)
f, err := os.Create(testData)
if err != nil {
t.Error(err)
}
Expand Down
6 changes: 3 additions & 3 deletions put_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestPutError(t *testing.T) {
defer os.RemoveAll(tmpDir)
file1 := filepath.Join(tmpDir, "file1")
remoteLocation := filepath.Join(tmpDir, "remote_loc")
f, err := os.OpenFile(file1, os.O_CREATE|os.O_WRONLY, readWriteFileMode)
f, err := os.Create(file1)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -250,7 +250,7 @@ func TestPutWithAutoCompressFalse(t *testing.T) {
}
defer os.RemoveAll(tmpDir)
testData := filepath.Join(tmpDir, "data.txt")
f, err := os.OpenFile(testData, os.O_CREATE|os.O_WRONLY, readWriteFileMode)
f, err := os.Create(testData)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -291,7 +291,7 @@ func TestPutOverwrite(t *testing.T) {
}
defer os.RemoveAll(tmpDir)
testData := filepath.Join(tmpDir, "data.txt")
f, err := os.OpenFile(testData, os.O_CREATE|os.O_RDWR, readWriteFileMode)
f, err := os.Create(testData)
if err != nil {
t.Error(err)
}
Expand Down

0 comments on commit f556352

Please sign in to comment.