lib9p

Go 9P library.
Log | Files | Refs | LICENSE

commit 4eba7dde4a57d0f160f6bca86c6c9a24ab8826f0
parent 845a25ee47c56da214affd6ea1478056813260c2
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Fri,  5 Jan 2024 10:07:05 +0900

implement client.TestFileStat

Diffstat:
Mclient/file_test.go | 29++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/client/file_test.go b/client/file_test.go @@ -4,7 +4,9 @@ import ( "context" "fmt" "io" + "io/fs" "path" + "reflect" "strings" "testing" @@ -25,11 +27,36 @@ func mount(fs lib9p.FS) (cfs *FS, cancel context.CancelFunc, err error) { return cfs, cancel, nil } -// TestFileStat tests whether Stat returns the same lib9p.Stat as testfs.Fsys defines. +// TestFileStat tests whether Stat returns the same lib9p.Stat as testfs defines. // TODO: work in progress. func TestFileStat(t *testing.T) { + cfs, cancel, err := mount(testfs) + if err != nil { + t.Fatal(err) + } + defer cancel() + defer cfs.Unmount() + var testFileStat = func(path string, d fs.DirEntry, err error) error { + t.Log("walk:", path) + fi, err := fs.Stat(lib9p.ExportFS{testfs}, path) + if err != nil { + t.Error(err) + } + cfi, err := d.Info() + if err != nil { + t.Error(err) + } + if !reflect.DeepEqual(cfi, fi) { + t.Errorf("fi not match:\n\twant: %v\n\tgot: %v", fi, cfi) + } + return nil + } + if err := fs.WalkDir(lib9p.ExportFS{cfs}, ".", testFileStat); err != nil { + t.Error(err) + } } + // TestReadDir tests whether ReadDir returns the same dir entries as testfs.Fsys // has. func TestReadDir(t *testing.T) {