commit 892e8c38583540354f083ef33f839661b04040f7
parent 029882122750da85f908f6159c8bbf7e27f60e6c
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sat, 28 Oct 2023 08:47:13 +0900
update client_test
Diffstat:
| M | client/client_test.go | | | 86 | +++---------------------------------------------------------------------------- |
1 file changed, 3 insertions(+), 83 deletions(-)
diff --git a/client/client_test.go b/client/client_test.go
@@ -3,11 +3,11 @@ package client
import (
"context"
"io"
- "io/fs"
"sync"
"testing"
"git.mtkn.jp/lib9p"
+ "git.mtkn.jp/lib9p/testfs"
)
const (
@@ -101,7 +101,7 @@ func TestTransaction(t *testing.T) {
cr, sw := io.Pipe()
sr, cw := io.Pipe()
- server := lib9p.NewServer(fsys, mSize, sr, sw)
+ server := lib9p.NewServer(testfs.FS, mSize, sr, sw)
//server.Chatty()
client := NewClient(mSize, uname, cr, cw)
tPool := newTagPool()
@@ -146,7 +146,7 @@ func TestClient2(t *testing.T) {
cr, sw := io.Pipe()
sr, cw := io.Pipe()
- server := lib9p.NewServer(fsys, mSize, sr, sw)
+ server := lib9p.NewServer(testfs.FS, mSize, sr, sw)
//server.Chatty()
go server.Serve(context.Background())
@@ -169,83 +169,3 @@ func TestClient2(t *testing.T) {
}
t.Log(string(b[:n]))
}
-
-var fsys *lib9p.TestFS
-
-func init() {
- fsys = &lib9p.TestFS{
- Root: &lib9p.TestFile{
- St: lib9p.Stat{
- Qid: lib9p.Qid{Path: 0, Type: lib9p.QTDIR},
- Mode: lib9p.FileMode(fs.ModeDir | 0755),
- Name: "root",
- Uid: "glenda",
- Gid: "glenda",
- Muid: "glenda",
- },
- Children: []*lib9p.TestFile{
- &lib9p.TestFile{
- Content: []byte("a\n"),
- St: lib9p.Stat{
- Qid: lib9p.Qid{Path: 1, Type: lib9p.QTFILE},
- Mode: lib9p.FileMode(0644),
- Name: "a",
- Uid: "glenda",
- Gid: "glenda",
- Muid: "glenda",
- },
- },
- &lib9p.TestFile{
- Content: []byte("b\n"),
- St: lib9p.Stat{
- Qid: lib9p.Qid{Path: 2, Type: lib9p.QTFILE},
- Mode: lib9p.FileMode(0400),
- Name: "b",
- Uid: "ken",
- Gid: "ken",
- Muid: "ken",
- },
- },
- &lib9p.TestFile{
- St: lib9p.Stat{
- Qid: lib9p.Qid{Path: 3, Type: lib9p.QTDIR},
- Mode: lib9p.FileMode(fs.ModeDir | 0755),
- Name: "dir",
- Uid: "rob",
- Gid: "rob",
- Muid: "rob",
- },
- Children: []*lib9p.TestFile{
- &lib9p.TestFile{
- Content: []byte("unko\n"),
- St: lib9p.Stat{
- Qid: lib9p.Qid{Path: 4, Type: lib9p.QTFILE},
- Mode: lib9p.FileMode(0666),
- Name: "file",
- Uid: "brian",
- Gid: "brian",
- Muid: "dennis",
- },
- },
- },
- },
- },
- },
- }
- SetFsysAndParent(fsys, nil)
-}
-
-// SetFsysAndParent sets file.fsys and file.parent for every file in the fsys.
-// Pass nil as file to setup entire file system.
-func SetFsysAndParent(fsys *lib9p.TestFS, file *lib9p.TestFile) {
- if file == nil {
- file = fsys.Root
- file.Parent = fsys.Root
- file.Fsys = fsys
- }
- for _, child := range file.Children {
- child.Parent = file
- child.Fsys = fsys
- SetFsysAndParent(fsys, child)
- }
-}