Skip to content

Commit

Permalink
Replace deprecated 'io/ioutil' package with 'os'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Jan 8, 2024
1 parent 3969df7 commit 242715d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"embed"
"errors"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -240,7 +239,7 @@ func TestOptions_Skip(t *testing.T) {
}}
err := Copy("test/data/case06", "test/data.copy/case06.01", opt)
Expect(t, err).ToBe(errInsideSkipFunc)
files, err := ioutil.ReadDir("./test/data.copy/case06.01")
files, err := os.ReadDir("./test/data.copy/case06.01")
Expect(t, err).ToBe(nil)
Expect(t, len(files)).ToBe(0)
})
Expand Down Expand Up @@ -326,7 +325,7 @@ func TestOptions_OnDirExists(t *testing.T) {
Expect(t, err).ToBe(nil)
err = Copy("test/data/case10/src", "test/data.copy/case10/dest.1", opt)
Expect(t, err).ToBe(nil)
b, err := ioutil.ReadFile("test/data.copy/case10/dest.1/" + "foo/" + "text_aaa")
b, err := os.ReadFile("test/data.copy/case10/dest.1/" + "foo/" + "text_aaa")
Expect(t, err).ToBe(nil)
Expect(t, string(b)).ToBe("This is text_aaa from src")
stat, err := os.Stat("test/data.copy/case10/dest.1/foo/text_eee")
Expand All @@ -340,7 +339,7 @@ func TestOptions_OnDirExists(t *testing.T) {
Expect(t, err).ToBe(nil)
err = Copy("test/data/case10/src", "test/data.copy/case10/dest.2", opt)
Expect(t, err).ToBe(nil)
b, err = ioutil.ReadFile("test/data.copy/case10/dest.2/" + "foo/" + "text_aaa")
b, err = os.ReadFile("test/data.copy/case10/dest.2/" + "foo/" + "text_aaa")
Expect(t, err).ToBe(nil)
Expect(t, string(b)).ToBe("This is text_aaa from src")
stat, err = os.Stat("test/data.copy/case10/dest.2/foo/text_eee")
Expand All @@ -352,7 +351,7 @@ func TestOptions_OnDirExists(t *testing.T) {
}
err = Copy("test/data/case10/src", "test/data.copy/case10/dest.3", opt)
Expect(t, err).ToBe(nil)
b, err = ioutil.ReadFile("test/data.copy/case10/dest.3/" + "foo/" + "text_aaa")
b, err = os.ReadFile("test/data.copy/case10/dest.3/" + "foo/" + "text_aaa")
Expect(t, err).ToBe(nil)
Expect(t, string(b)).ToBe("This is text_aaa from dest")

Expand All @@ -374,7 +373,7 @@ func TestOptions_CopyBufferSize(t *testing.T) {
err := Copy("test/data/case12", "test/data.copy/case12", opt)
Expect(t, err).ToBe(nil)

content, err := ioutil.ReadFile("test/data.copy/case12/README.md")
content, err := os.ReadFile("test/data.copy/case12/README.md")
Expect(t, err).ToBe(nil)
Expect(t, string(content)).ToBe("case12 - README.md")
}
Expand Down

0 comments on commit 242715d

Please sign in to comment.