feat(fileutil): add CopyDir func (#180)

* add fileutil.CopyDir

* remove debug code
This commit is contained in:
yunxuan authored and GitHub committed 2024-02-25 20:25:00 +08:00
1 parent aebab7c944
commit 0eeaa06055
7 files changed
+141 -1

No files matched your search

+22
View File
@@ -3,6 +3,8 @@ package fileutil
import (
"io"
"os"
"path/filepath"
"strings"
"testing"
"github.com/duke-git/lancet/v2/internal"
@@ -544,3 +546,23 @@ func TestReadlineFile(t *testing.T) {
internal.NewAssert(t, "TestReadlineFile").Equal(line, lineRead)
}
}
func TestCopyDir(t *testing.T) {
assert := internal.NewAssert(t, "TestCopyDir")
src := "./testdata"
dest := "./testdata_copy"
err := CopyDir(src, dest)
assert.IsNil(err)
assert.Equal(true, IsExist(dest))
filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
destPath := strings.Replace(path, src, dest, 1)
assert.Equal(true, IsExist(destPath))
return nil
})
os.RemoveAll(dest)
}