good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 6b38ebbb authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Test fixes

parent 85f249d1
No related branches found
No related tags found
No related merge requests found
......@@ -142,7 +142,7 @@ func TestConn(t *testing.T) {
defer c1.Close(websocket.StatusInternalError, "")
defer c2.Close(websocket.StatusInternalError, "")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
defer cancel()
c2.CloseRead(ctx)
......@@ -163,7 +163,7 @@ func TestConn(t *testing.T) {
defer c2.Close(websocket.StatusInternalError, "")
defer c1.Close(websocket.StatusInternalError, "")
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
defer cancel()
discardLoopErr := xsync.Go(func() error {
......@@ -242,7 +242,7 @@ func TestConn(t *testing.T) {
defer c2.Close(websocket.StatusInternalError, "")
defer c1.Close(websocket.StatusInternalError, "")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
defer cancel()
n1 := websocket.NetConn(ctx, c1, websocket.MessageBinary)
......@@ -298,7 +298,7 @@ func TestConn(t *testing.T) {
defer c2.Close(websocket.StatusInternalError, "")
defer c1.Close(websocket.StatusInternalError, "")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
defer cancel()
n1 := websocket.NetConn(ctx, c1, websocket.MessageBinary)
......@@ -333,7 +333,7 @@ func TestConn(t *testing.T) {
defer c2.Close(websocket.StatusInternalError, "")
defer c1.Close(websocket.StatusInternalError, "")
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
defer cancel()
echoLoopErr := xsync.Go(func() error {
......@@ -351,10 +351,10 @@ func TestConn(t *testing.T) {
c1.SetReadLimit(131072)
exp := xrand.String(xrand.Int(131072))
err = wsjson.Write(ctx, c1, exp)
if err != nil {
t.Fatal(err)
}
werr := xsync.Go(func() error {
return wsjson.Write(ctx, c1, exp)
})
var act interface{}
err = wsjson.Read(ctx, c1, &act)
......@@ -365,6 +365,11 @@ func TestConn(t *testing.T) {
t.Fatal(cmp.Diff(exp, act))
}
err = <-werr
if err != nil {
t.Fatal(err)
}
err = c1.Close(websocket.StatusNormalClosure, "")
if err != nil {
t.Fatalf("unexpected error: %v", err)
......@@ -381,7 +386,7 @@ func TestConn(t *testing.T) {
defer c2.Close(websocket.StatusInternalError, "")
defer c1.Close(websocket.StatusInternalError, "")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
defer cancel()
echoLoopErr := xsync.Go(func() error {
......
package wstest
import (
"bytes"
"context"
"io"
"time"
......@@ -75,7 +76,7 @@ func Echo(ctx context.Context, c *websocket.Conn, max int) error {
return xerrors.Errorf("unexpected message typ (%v): %v", expType, actType)
}
if !cmp.Equal(msg, act) {
if !bytes.Equal(msg, act) {
return xerrors.Errorf("unexpected msg read: %v", cmp.Diff(msg, act))
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment