summaryrefslogtreecommitdiff
path: root/net_test.go
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2022-06-05 23:52:55 +0100
committerGrégoire Duchêne <gduchene@awhk.org>2022-06-05 23:52:55 +0100
commit17148b7d2981d98309f7346435f5d3e77c586ab4 (patch)
treebf97393e633a6bb530e96e62af11c93919013fbe /net_test.go
parent0315338ef5c5fadd739088684323b82535fc904b (diff)
Add ListenPipe
Also, PipeListener.Close now returns syscall.EINVAL if the PipeListener was closed already. This imitates the behavior of net.UnixListener.
Diffstat (limited to 'net_test.go')
-rw-r--r--net_test.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/net_test.go b/net_test.go
index 505579e..3c01a15 100644
--- a/net_test.go
+++ b/net_test.go
@@ -12,7 +12,7 @@ func TestPipeListener(s *testing.T) {
t := core.T{T: s}
t.Run("Success", func(t *core.T) {
- p := &core.PipeListener{}
+ p := core.ListenPipe()
t.Go(func() {
conn, err := p.Accept()
@@ -26,7 +26,7 @@ func TestPipeListener(s *testing.T) {
})
t.Run("WhenClosed", func(t *core.T) {
- p := &core.PipeListener{}
+ p := core.ListenPipe()
p.Close()
conn, err := p.Accept()
@@ -38,8 +38,14 @@ func TestPipeListener(s *testing.T) {
t.AssertEqual(nil, conn)
})
+ t.Run("WhenClosedTwice", func(t *core.T) {
+ p := core.ListenPipe()
+ t.AssertEqual(nil, p.Close())
+ t.AssertEqual(syscall.EINVAL, p.Close())
+ })
+
t.Run("WhenContextCanceled", func(t *core.T) {
- p := &core.PipeListener{}
+ p := core.ListenPipe()
ctx, cancel := context.WithCancel(context.Background())
cancel()