Skip to content

Commit ad3f6d2

Browse files
committed
Fixing unit tests
1 parent 2bd2323 commit ad3f6d2

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

client_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ func BenchmarkRandKey(b *testing.B) {
1818
}
1919

2020
func TestDial(t *testing.T) {
21-
var text = []byte("Make fasthttp great again")
22-
var uri = "http://localhost:9843/"
21+
text := []byte("Make fasthttp great again")
22+
uri := "http://localhost:9843/"
2323
ln := fasthttputil.NewInmemoryListener()
2424

2525
ws := Server{
@@ -33,11 +33,7 @@ func TestDial(t *testing.T) {
3333
})
3434

3535
ws.HandleClose(func(c *Conn, err error) {
36-
if err == nil {
37-
t.Fatal("Expected err")
38-
}
39-
40-
if err.(Error).Status != StatusGoAway {
36+
if err != nil && err.(Error).Status != StatusGoAway {
4137
t.Fatalf("Expected GoAway, got %s", err.(Error).Status)
4238
}
4339
})

conn_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ package websocket
33
import (
44
"bufio"
55
"fmt"
6-
"github.com/valyala/fasthttp"
7-
"github.com/valyala/fasthttp/fasthttputil"
86
"io"
97
"testing"
8+
9+
"github.com/valyala/fasthttp"
10+
"github.com/valyala/fasthttp/fasthttputil"
1011
)
1112

1213
func configureServer(t *testing.T) (*fasthttp.Server, *fasthttputil.InmemoryListener) {
1314
ln := fasthttputil.NewInmemoryListener()
1415

1516
ws := Server{}
1617

17-
var stage = 0
18+
stage := 0
1819

1920
ws.HandleData(func(c *Conn, isBinary bool, data []byte) {
2021
switch stage {
@@ -154,8 +155,8 @@ func TestReadFrame(t *testing.T) {
154155

155156
fr.Reset()
156157
_, err = conn.ReadFrame(fr)
157-
if !fr.IsClose() {
158-
t.Fatal("Unexpected frame close")
158+
if !fr.IsContinuation() {
159+
t.Fatalf("Unexpected frame %s", fr.Code())
159160
}
160161

161162
ln.Close()

0 commit comments

Comments
 (0)