From f55635248ac775437a5cacf06d6a286cc677e173 Mon Sep 17 00:00:00 2001 From: ramikg <72725910+ramikg@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:57:27 +0300 Subject: [PATCH] Replace `os.OpenFile` with `os.Create` in tests --- encrypt_util_test.go | 8 ++++---- file_transfer_agent_test.go | 2 +- put_get_test.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/encrypt_util_test.go b/encrypt_util_test.go index 1480a3ab9..5d0d9988b 100644 --- a/encrypt_util_test.go +++ b/encrypt_util_test.go @@ -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) } @@ -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 } @@ -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 } @@ -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 } diff --git a/file_transfer_agent_test.go b/file_transfer_agent_test.go index f48ba6268..ce94dfbe5 100644 --- a/file_transfer_agent_test.go +++ b/file_transfer_agent_test.go @@ -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) } diff --git a/put_get_test.go b/put_get_test.go index 93f2a9fa8..0bfce1f36 100644 --- a/put_get_test.go +++ b/put_get_test.go @@ -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) } @@ -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) } @@ -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) }