Skip to content

Commit 4bb56f3

Browse files
author
youthlin
committed
add test
1 parent 529d2a5 commit 4bb56f3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

fs_test.go

+20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package t
22

33
import (
44
"io/fs"
5+
"os"
56
"testing"
7+
"path/filepath"
68

79
. "github.com/smartystreets/goconvey/convey"
810
)
@@ -43,4 +45,22 @@ func Test_asFS(t *testing.T) {
4345
})
4446
})
4547
})
48+
49+
// Join 会去除后面的点
50+
t.Logf("%v", filepath.Join("testdata/zh_CN.mo", "."))
51+
52+
// os.DirFS Open 时,是直接用 / 连接的
53+
f := os.DirFS("testdata/zh_CN.mo")
54+
fs.WalkDir(f, ".", func(path string, d fs.DirEntry, err error) error {
55+
// path=. | d= <nil> | err=stat testdata/zh_CN.mo/.: not a directory
56+
t.Logf("path=%v | d= %v | err=%v", path, d, err)
57+
return err
58+
})
59+
// adFS Open 时,用的 Join
60+
f = asFS("testdata/zh_CN.mo")
61+
fs.WalkDir(f, ".", func(path string, d fs.DirEntry, err error) error {
62+
// path=. | d= zh_CN.mo | err=<nil>
63+
t.Logf("path=%v | d= %v | err=%v", path, d.Name(), err)
64+
return err
65+
})
4666
}

0 commit comments

Comments
 (0)