mirror of
https://github.com/soheilhy/cmux.git
synced 2025-01-18 18:56:26 +08:00
Add test for multiple matchers
This commit is contained in:
parent
cfc68f9888
commit
444ce56efe
29
cmux_test.go
29
cmux_test.go
@ -622,6 +622,35 @@ func TestErrorHandler(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMultipleMatchers(t *testing.T) {
|
||||
defer leakCheck(t)()
|
||||
errCh := make(chan error)
|
||||
defer func() {
|
||||
select {
|
||||
case err := <-errCh:
|
||||
t.Fatal(err)
|
||||
default:
|
||||
}
|
||||
}()
|
||||
l, cleanup := testListener(t)
|
||||
defer cleanup()
|
||||
|
||||
matcher := func(r io.Reader) bool {
|
||||
return true
|
||||
}
|
||||
unmatcher := func(r io.Reader) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
muxl := New(l)
|
||||
lis := muxl.Match(unmatcher, matcher, unmatcher)
|
||||
|
||||
go runTestHTTPServer(errCh, lis)
|
||||
go safeServe(errCh, muxl)
|
||||
|
||||
runTestHTTP1Client(t, l.Addr())
|
||||
}
|
||||
|
||||
func TestClose(t *testing.T) {
|
||||
defer leakCheck(t)()
|
||||
errCh := make(chan error)
|
||||
|
Loading…
Reference in New Issue
Block a user