lib9p

Go 9P library.
Log | Files | Refs | LICENSE

commit 8985476eda283200d261c750abbe2919d40cf729
parent e0d7f1074b77c0bb3bdd751f878c1e307da9ae69
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Thu, 28 Dec 2023 11:37:00 +0900

add TestSFlush

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

diff --git a/server2_test.go b/server2_test.go @@ -226,3 +226,28 @@ func TestSAuth(t *testing.T) { }() } } + +func TestSFlush(t *testing.T) { + rp := newReqPool() + tests := []struct { + input *Req + }{ + {&Req{Ifcall: &TFlush{}, + Oldreq: &Req{pool: rp, done: make(chan struct{})}}}, + } + tc := make(chan *Req) + rc := make(chan *Req) + s := &Server{msize: 1024, mSizeLock: new(sync.Mutex), respChan: rc} + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + go sFlush(ctx, s, tc) + for _, test := range tests { + tc <- test.input + if gotmsg, ok := (<-rc).Ofcall.(*RFlush); !ok { + t.Errorf("unexpected message: %v", gotmsg) + } + if _, ok := <-test.input.Oldreq.done; ok { + t.Errorf("done channel not closed") + } + } +}