lib9p

Go 9P library.
Log | Files | Refs

commit 74f108c38a6d5f05b5e7e4495e53ccdee20bff09
parent aa739a27a51e99752a05635f69dac6df4e963b5b
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Fri,  6 Oct 2023 06:23:38 +0900

add Attach to test

Diffstat:
Mclient.go | 25+++++++++++++++++++++++++
Mclient_test.go | 7++++++-
2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/client.go b/client.go @@ -161,3 +161,27 @@ func (c *Client) Auth(ctx context.Context, afid uint32, uname, aname string) (*R } } +func (c *Client) Attach(ctx context.Context, fid, afid uint32, uname, aname string) (*RAttach, error) { + tmsg := &TAttach{ + fid: fid, + afid: afid, + uname: uname, + aname: aname, + } + rmsgc, errc := c.transact(ctx, tmsg) + select { + case rmsg := <-rmsgc: + switch rmsg := rmsg.(type) { + case *RAttach: + return rmsg, nil + case *RError: + return nil, rmsg.ename + default: + return nil, fmt.Errorf("invalid R message: %v", rmsg) + } + case err := <-errc: + return nil, err + case <-ctx.Done(): + return nil, fmt.Errorf("wait transaction: %w", ctx.Err()) + } +} +\ No newline at end of file diff --git a/client_test.go b/client_test.go @@ -33,7 +33,12 @@ func TestTransaction(t *testing.T) { } else { t.Log(rauth) } - + rattach, err := client.Attach(bg, 0, NOFID, "kenji", "") + if err != nil { + t.Log(err) + } else { + t.Log(rattach) + } } func TestClientVersion(t *testing.T) {