@@ -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