@@ -47,10 +47,7 @@ func TestHandshake(t *testing.T) {
47
47
c .Close (websocket .StatusInternalError , "" )
48
48
return xerrors .New ("expected error regarding bad origin" )
49
49
}
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" )
54
51
},
55
52
client : func (ctx context.Context , u string ) error {
56
53
h := http.Header {}
@@ -62,10 +59,7 @@ func TestHandshake(t *testing.T) {
62
59
c .Close (websocket .StatusInternalError , "" )
63
60
return xerrors .New ("expected handshake failure" )
64
61
}
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" )
69
63
},
70
64
},
71
65
{
@@ -123,8 +117,9 @@ func TestHandshake(t *testing.T) {
123
117
if err != nil {
124
118
return xerrors .Errorf ("request is missing mycookie: %w" , err )
125
119
}
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
128
123
}
129
124
c , err := websocket .Accept (w , r , nil )
130
125
if err != nil {
0 commit comments