Documentation ¶
Overview ¶
Package p9test provides standard mocks for p9.
Index ¶
- func MakePath() uint64
- type Generator
- type Harness
- func (h *Harness) Finish()
- func (h *Harness) NewBlockDevice() Generator
- func (h *Harness) NewCharacterDevice() Generator
- func (h *Harness) NewDirectory(contents map[string]Generator) Generator
- func (h *Harness) NewFile() Generator
- func (h *Harness) NewMock(parent *Mock, path uint64, attr p9.Attr) *Mock
- func (h *Harness) NewNamedPipe() Generator
- func (h *Harness) NewSocket() Generator
- func (h *Harness) NewSymlink() Generator
- func (h *Harness) Pop(clientFile p9.File) *Mock
- type Mock
- func (m *Mock) AddChild(name string, generator Generator)
- func (m *Mock) GetAttr(mask p9.AttrMask) (p9.QID, p9.AttrMask, p9.Attr, error)
- func (m *Mock) Matches(x interface{}) bool
- func (m *Mock) RemoveChild(name string)
- func (m *Mock) String() string
- func (m *Mock) Walk(names []string) ([]p9.QID, p9.File, error)
- func (m *Mock) WalkGetAttr(names []string) ([]p9.QID, p9.File, p9.AttrMask, p9.Attr, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Harness ¶
type Harness struct { Attacher *MockAttacher // contains filtered or unexported fields }
Harness is an attacher mock.
func NewHarness ¶
NewHarness creates and returns a new test server.
It should always be used as:
h, c := NewHarness(t) defer h.Finish()
func (*Harness) Finish ¶
func (h *Harness) Finish()
Finish completes all checks and shuts down the server.
func (*Harness) NewBlockDevice ¶
NewBlockDevice returns a new mock block device.
func (*Harness) NewCharacterDevice ¶
NewCharacterDevice returns a new mock character device.
func (*Harness) NewDirectory ¶
NewDirectory returns a new mock directory.
Note that Mkdir, Link, Mknod, RenameAt, UnlinkAt and Readdir must be mocked separately. Walk is provided and children may be manipulated via AddChild and RemoveChild. After calling Walk remotely, one can use Pop to find the corresponding backend mock on the server side.
func (*Harness) NewFile ¶
NewFile returns a new file mock.
Note that ReadAt and WriteAt must be mocked separately.
func (*Harness) NewNamedPipe ¶
NewNamedPipe returns a new mock named pipe.
func (*Harness) NewSymlink ¶
NewSymlink returns a new mock directory.
Note that Readlink must be mocked separately.
type Mock ¶
type Mock struct { p9.DefaultWalkGetAttr *MockFile QID p9.QID Attr p9.Attr // WalkCallback is a special function that will be called from within // the walk context. This is needed for the concurrent tests within // this package. WalkCallback func() error // contains filtered or unexported fields }
Mock is a common mock element.
func (*Mock) RemoveChild ¶
RemoveChild removes the child with the given name.