1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
package listener
import (
"net"
"testing"
)
// Helper for tests acting on a single accepted connection
func singleConn(t *testing.T, m mode) (*T, *fakeConn, net.Conn) {
l := makeFakeListener("net.Listener")
wl := Wrap(l, m)
c := makeFakeConn("local", "remote")
go l.Enqueue(c)
wc, err := wl.Accept()
if err != nil {
t.Fatalf("error accepting connection: %v", err)
}
return wl, c, wc
}
func TestAddr(t *testing.T) {
}
func TestBasicCloseIdle(t *testing.T) {
}
func TestMark(t *testing.T) {
}
func TestDisown(t *testing.T) {
}
func TestDrain(t *testing.T) {
}
func TestDrainAll(t *testing.T) {
}
func TestErrors(t *testing.T) {
t.Parallel()
_, c, wc := singleConn(t, Manual)
if err := Disown(c); err == nil {
t.Error("expected error when disowning unmanaged net.Conn")
}
if err := MarkIdle(c); err == nil {
t.Error("expected error when marking unmanaged net.Conn idle")
}
if err := MarkInUse(c); err == nil {
t.Error("expected error when marking unmanaged net.Conn in use")
}
if err := Disown(wc); err != nil {
t.Fatalf("unexpected error disowning socket: %v", err)
}
if err := Disown(wc); err == nil {
t.Error("expected error disowning socket twice")
}
}
func TestClose(t *testing.T) {
}
|