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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user