1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-17 03:02:28 +08:00

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

* add fileutil.CopyDir

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

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)
}