Skip to content

Commit

Permalink
fix staticcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 19, 2021
1 parent efdc4d9 commit 2be60f5
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions gostream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gostream
import (
"bufio"
"context"
"io"
"testing"
"time"

Expand Down Expand Up @@ -45,38 +46,44 @@ func TestServerClient(t *testing.T) {
go func(ctx context.Context) {
listener, err := Listen(srvHost, tag)
if err != nil {
t.Fatal(err)
t.Error(err)
return
}
defer listener.Close()

if listener.Addr().String() != srvHost.ID().Pretty() {
t.Fatal("bad listener address")
t.Error("bad listener address")
return
}

servConn, err := listener.Accept()
if err != nil {
t.Fatal(err)
t.Error(err)
return
}
defer servConn.Close()

reader := bufio.NewReader(servConn)
for {
msg, err := reader.ReadString('\n')
if err == io.EOF {
break
}
if err != nil {
t.Fatal(err)
t.Error(err)
return
}
if string(msg) != "is libp2p awesome?\n" {
t.Fatalf("Bad incoming message: %s", msg)
if msg != "is libp2p awesome?\n" {
t.Errorf("Bad incoming message: %s", msg)
return
}

_, err = servConn.Write([]byte("yes it is\n"))
if err != nil {
t.Fatal(err)
}
select {
case <-ctx.Done():
t.Error(err)
return
}
<-ctx.Done()
}
}(ctx)

Expand Down

0 comments on commit 2be60f5

Please sign in to comment.