Skip to content

Commit 15cca63

Browse files
committed
Merge branch 'test'
2 parents 23a3ede + 3c34db4 commit 15cca63

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

websocket_autobahn_python_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// This file contains the old autobahn test suite tests that use the
2+
// python binary. The approach is very clunky and slow so new tests
3+
// have been written in pure Go in websocket_test.go.
14
// +build autobahn-python
25

36
package websocket_test

websocket_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ func TestHandshake(t *testing.T) {
4747
c.Close(websocket.StatusInternalError, "")
4848
return xerrors.New("expected error regarding bad origin")
4949
}
50-
if !strings.Contains(err.Error(), "not authorized") {
51-
return xerrors.Errorf("expected error regarding bad origin: %+v", err)
52-
}
53-
return nil
50+
return assertErrorContains(err, "not authorized")
5451
},
5552
client: func(ctx context.Context, u string) error {
5653
h := http.Header{}
@@ -62,10 +59,7 @@ func TestHandshake(t *testing.T) {
6259
c.Close(websocket.StatusInternalError, "")
6360
return xerrors.New("expected handshake failure")
6461
}
65-
if !strings.Contains(err.Error(), "403") {
66-
return xerrors.Errorf("expected handshake failure: %+v", err)
67-
}
68-
return nil
62+
return assertErrorContains(err, "403")
6963
},
7064
},
7165
{
@@ -123,8 +117,9 @@ func TestHandshake(t *testing.T) {
123117
if err != nil {
124118
return xerrors.Errorf("request is missing mycookie: %w", err)
125119
}
126-
if cookie.Value != "myvalue" {
127-
return xerrors.Errorf("expected %q but got %q", "myvalue", cookie.Value)
120+
err = assertEqualf("myvalue", cookie.Value, "unexpected cookie value")
121+
if err != nil {
122+
return err
128123
}
129124
c, err := websocket.Accept(w, r, nil)
130125
if err != nil {

0 commit comments

Comments
 (0)