Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
youthlin committed Jan 12, 2023
1 parent 529d2a5 commit 4bb56f3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package t

import (
"io/fs"
"os"
"testing"
"path/filepath"

. "github.com/smartystreets/goconvey/convey"
)
Expand Down Expand Up @@ -43,4 +45,22 @@ func Test_asFS(t *testing.T) {
})
})
})

// Join 会去除后面的点
t.Logf("%v", filepath.Join("testdata/zh_CN.mo", "."))

// os.DirFS Open 时,是直接用 / 连接的
f := os.DirFS("testdata/zh_CN.mo")
fs.WalkDir(f, ".", func(path string, d fs.DirEntry, err error) error {
// path=. | d= <nil> | err=stat testdata/zh_CN.mo/.: not a directory
t.Logf("path=%v | d= %v | err=%v", path, d, err)
return err
})
// adFS Open 时,用的 Join
f = asFS("testdata/zh_CN.mo")
fs.WalkDir(f, ".", func(path string, d fs.DirEntry, err error) error {
// path=. | d= zh_CN.mo | err=<nil>
t.Logf("path=%v | d= %v | err=%v", path, d.Name(), err)
return err
})
}

0 comments on commit 4bb56f3

Please sign in to comment.