commit b01fec8e713dfad02aa0d8ffe520f144a172d1fb
parent 86c88bd52202efd11839f3373206d8aeaaca7450
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sun, 14 Jan 2024 07:10:30 +0900
refactor tests
Diffstat:
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/server_test.go b/server_test.go
@@ -784,25 +784,28 @@ func TestSRemove(t *testing.T) {
func() {
fid, err := c.fPool.add(test.fid)
if err != nil {
- t.Error(err)
+ t.Error(i, err)
return
}
defer c.fPool.delete(test.fid)
fid.omode = -1
fid.path = test.pathname
- f, err := testfs.Create(test.pathname, test.fuid, test.mode, test.perm)
- if err != nil {
- t.Fatal(i, err)
- }
- defer f.Close()
- fid.file = f
- fi, err := f.Stat()
- if err != nil {
- t.Fatal(i, err)
- }
- fid.qidpath = fi.Sys().(*Stat).Qid.Path
+ fid.file = &testFile{stat: Stat{Name:path.Base(test.pathname)}}
fid.uid = test.ruid
fid.fs = testfs
+ dir, err := testfs.walkPath(path.Dir(test.pathname))
+ if err != nil {
+ t.Error(i, err)
+ return
+ }
+ dir.children = append(dir.children, fid.file.(*testFile))
+ defer func() {
+ if 0 < len(dir.children) &&
+ dir.children[len(dir.children)-1].stat.Name ==
+ path.Base(test.pathname) {
+ dir.children = dir.children[:len(dir.children)-1]
+ }
+ }()
tc <- &request{ifcall: test.ifcall}
ofcall := (<-rc).ofcall
switch ofcall := ofcall.(type) {