Skip to content

Commit 95a7ca4

Browse files
committed
msg and test update
1 parent 1cb43c8 commit 95a7ca4

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

filepath.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func doWalk(fname string, linkName string, walkFn filepath.WalkFunc) error {
154154
// CopyFile copies the given source file into destination
155155
func CopyFile(dest, src string) (int64, error) {
156156
if !IsFileExists(src) {
157-
return 0, fmt.Errorf("source file is not exists: %v", src)
157+
return 0, fmt.Errorf("source file does not exists: %v", src)
158158
}
159159

160160
baseName := filepath.Base(src)
@@ -191,7 +191,7 @@ func CopyFile(dest, src string) (int64, error) {
191191
// and it excludes give file matches
192192
func CopyDir(dest, src string, excludes Excludes) error {
193193
if !IsFileExists(src) {
194-
return fmt.Errorf("source dir is not exists: %v", src)
194+
return fmt.Errorf("source dir does not exists: %v", src)
195195
}
196196

197197
src = filepath.Clean(src)

filepath_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,29 +185,29 @@ func TestCopyDir(t *testing.T) {
185185

186186
defer DeleteFiles(join(tmpDir, "test1"))
187187

188-
err := CopyDir(
188+
err1 := CopyDir(
189189
join(tmpDir, "target"),
190190
join(testdataPath, "not-exists-dir"),
191191
Excludes{},
192192
)
193-
assert.NotNil(t, err)
193+
assert.NotNil(t, err1)
194194

195-
err = CopyDir(
195+
err2 := CopyDir(
196196
join(tmpDir, "target"),
197197
join(testdataPath, "sample.txt"),
198198
Excludes{},
199199
)
200-
assert.NotNil(t, err)
200+
assert.NotNil(t, err2)
201201

202-
err = CopyDir(tmpDir, testdataPath, Excludes{})
203-
assert.True(t, strings.HasPrefix(err.Error(), "destination dir already exists"))
202+
err3 := CopyDir(tmpDir, testdataPath, Excludes{})
203+
assert.True(t, strings.HasPrefix(err3.Error(), "destination dir already exists"))
204204

205-
err = CopyDir(join(tmpDir, "target"), testdataPath, Excludes{"[]a]"})
206-
assert.NotNil(t, err)
205+
err4 := CopyDir(join(tmpDir, "target"), testdataPath, Excludes{"[]a]"})
206+
assert.NotNil(t, err4)
207207

208208
pwd, _ := os.Getwd()
209-
err = CopyDir(join(tmpDir, "test1"), pwd, Excludes{"test*", "*conf", ".*"})
210-
assert.FailNowOnError(t, err, "copy directory failed")
209+
err5 := CopyDir(join(tmpDir, "test1"), pwd, Excludes{"test*", "*conf", ".*"})
210+
assert.FailNowOnError(t, err5, "copy directory failed")
211211
}
212212

213213
func TestStripExt(t *testing.T) {
@@ -228,6 +228,7 @@ func TestDirPaths(t *testing.T) {
228228
path12 := join(testdataPath, "dirpaths", "level1", "level1-2")
229229
path21 := join(testdataPath, "dirpaths", "level1", "level2", "level2-1")
230230
path22 := join(testdataPath, "dirpaths", "level1", "level2", "level2-2")
231+
defer DeleteFiles(join(testdataPath, "dirpaths"))
231232

232233
_ = MkDirAll(path1, 0755)
233234
_ = MkDirAll(path11, 0755)

0 commit comments

Comments
 (0)