Skip to content

Commit

Permalink
Merge pull request #136 from alexandear/test-replace-deprecated-iouti…
Browse files Browse the repository at this point in the history
…l-with-os

Replace deprecated 'io/ioutil' package with 'os'
  • Loading branch information
otiai10 authored Jan 19, 2024
2 parents 441a9cd + 242715d commit 3048e24
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 @@ -206,7 +205,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 @@ -292,7 +291,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 @@ -306,7 +305,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 @@ -318,7 +317,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 @@ -340,7 +339,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 3048e24

Please sign in to comment.