Skip to content

Commit

Permalink
mount: use os.WriteFile in tests
Browse files Browse the repository at this point in the history
... instead of ioutil.WriteFile.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Mar 7, 2022
1 parent c8cbe59 commit 48d0b57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 5 additions & 6 deletions mount/mount_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package mount

import (
"io/ioutil"
"os"
"path"
"strings"
Expand Down Expand Up @@ -49,11 +48,11 @@ func TestMounted(t *testing.T) {
t.Fatal(err)
}

if err := ioutil.WriteFile(sourcePath, []byte("hello"), 0o644); err != nil {
if err := os.WriteFile(sourcePath, []byte("hello"), 0o644); err != nil {
t.Fatal(err)
}

if err := ioutil.WriteFile(targetPath, nil, 0o644); err != nil {
if err := os.WriteFile(targetPath, nil, 0o644); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -146,11 +145,11 @@ func TestMountReadonly(t *testing.T) {
t.Fatal(err)
}

if err := ioutil.WriteFile(sourcePath, []byte("hello"), 0o644); err != nil {
if err := os.WriteFile(sourcePath, []byte("hello"), 0o644); err != nil {
t.Fatal(err)
}

if err := ioutil.WriteFile(targetPath, nil, 0o644); err != nil {
if err := os.WriteFile(targetPath, nil, 0o644); err != nil {
t.Fatal(err)
}

Expand All @@ -163,7 +162,7 @@ func TestMountReadonly(t *testing.T) {
}
}()

if err := ioutil.WriteFile(targetPath, []byte("hello"), 0o644); err == nil {
if err := os.WriteFile(targetPath, []byte("hello"), 0o644); err == nil {
t.Fatal("Should not be able to open a ro file as rw")
}
}
Expand Down
3 changes: 1 addition & 2 deletions mount/sharedsubtree_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package mount

import (
"errors"
"io/ioutil"
"os"
"path"
"testing"
Expand Down Expand Up @@ -322,5 +321,5 @@ func TestSubtreeUnbindable(t *testing.T) {
}

func createFile(path string) error {
return ioutil.WriteFile(path, []byte("hello"), 0o666)
return os.WriteFile(path, []byte("hello"), 0o666)
}

0 comments on commit 48d0b57

Please sign in to comment.