lib9p

Go 9P library.
Log | Files | Refs

commit a82c7920022ddc0ecd89da50152f1d1383f91511
parent 7c429cc368f8cef0c21567e567f921617010561b
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Thu, 12 Oct 2023 17:37:10 +0900

delete old test

Diffstat:
Mclient_test.go | 111-------------------------------------------------------------------------------
1 file changed, 0 insertions(+), 111 deletions(-)

diff --git a/client_test.go b/client_test.go @@ -3,7 +3,6 @@ package lib9p import ( "context" "io" - "reflect" "sync" "testing" ) @@ -87,116 +86,6 @@ func TestClientVersion(t *testing.T) { } } -func TestClientAuth(t *testing.T) { - tests := []struct { - name string - tmsg *TAuth - rmsg Msg - wantrmsg Msg - }{ - {"0", &TAuth{tag: NOTAG, afid: 0, uname: uname, aname: ""}, - &RAuth{tag: NOTAG, aqid: Qid{0, 0, 0}}, - &RAuth{tag: NOTAG, aqid: Qid{0, 0, 0}}}, - } - for _, test := range tests { - func() { - tmsgc := make(chan Msg) - rmsgc := make(chan Msg) - c := newClientForTest(mSize, uname, tmsgc, rmsgc) - defer c.Stop() - bg := context.Background() - var ( - gotrmsg Msg - goterr error - wg sync.WaitGroup - ) - wg.Add(1) - go func() { - gotrmsg, goterr = c.Auth(bg, test.tmsg.afid, test.tmsg.uname, test.tmsg.aname) - wg.Done() - }() - gottmsg := <-tmsgc - tag := gottmsg.Tag() - test.tmsg.SetTag(tag) - test.rmsg.SetTag(tag) - test.wantrmsg.SetTag(tag) - if !reflect.DeepEqual(gottmsg, test.tmsg) { - t.Errorf("%s: input: %v, sent: %v", test.name, test.tmsg, gottmsg) - } - rmsgc <- test.rmsg - done := make(chan struct{}) - go func() { wg.Wait(); done <- struct{}{} }() - select { - case err := <-c.errc: - t.Errorf("client err: %v", err) - return - case <-done: - } - if !reflect.DeepEqual(gotrmsg, test.wantrmsg) { - t.Errorf("%s: want: %v, got: %v", test.name, test.wantrmsg, gotrmsg) - } - if goterr != nil { - t.Errorf("%s: goterr: %v", test.name, goterr) - } - }() - } -} - -func TestClientAttach(t *testing.T) { - tests := []struct { - name string - tmsg *TAttach - rmsg Msg - wantrmsg Msg - }{ - {"0", &TAttach{fid: 0, afid: NOFID, uname: uname, aname: ""}, - &RAttach{qid: Qid{0, 0, 0}}, - &RAttach{qid: Qid{0, 0, 0}}}, - } - for _, test := range tests { - func() { - tmsgc := make(chan Msg) - rmsgc := make(chan Msg) - c := newClientForTest(mSize, uname, tmsgc, rmsgc) - defer c.Stop() - bg := context.Background() - var ( - gotrmsg Msg - goterr error - wg sync.WaitGroup - ) - wg.Add(1) - go func() { - gotrmsg, goterr = c.Attach(bg, test.tmsg.fid, test.tmsg.afid, - test.tmsg.uname, test.tmsg.aname) - wg.Done() - }() - gottmsg := <-tmsgc - tag := gottmsg.Tag() - test.tmsg.SetTag(tag) - test.rmsg.SetTag(tag) - test.wantrmsg.SetTag(tag) - if !reflect.DeepEqual(gottmsg, test.tmsg) { - t.Errorf("%s: input: %v, sent: %v", test.name, test.tmsg, gottmsg) - } - rmsgc <- test.rmsg - done := make(chan struct{}) - go func() { wg.Wait(); done <- struct{}{} }() - select { - case err := <-c.errc: - t.Errorf("client err: %v", err) - return - case <-done: - } - if !reflect.DeepEqual(gotrmsg, test.wantrmsg) { - t.Errorf("%s: want: %v, got: %v", test.name, test.wantrmsg, gotrmsg) - } - if goterr != nil { - t.Errorf("%s: goterr: %v", test.name, goterr) - } - }() - } -} // the following tests are test for both client and server. // should be moved to propper file.