diff --git a/websocket_autobahn_python_test.go b/websocket_autobahn_python_test.go index 32ee1f5ceeeaf89377ddffdfc1b3a34b234bc493..0512c85a238c240c07ade72644500c8baf3b0aa1 100644 --- a/websocket_autobahn_python_test.go +++ b/websocket_autobahn_python_test.go @@ -1,3 +1,6 @@ +// This file contains the old autobahn test suite tests that use the +// python binary. The approach is very clunky and slow so new tests +// have been written in pure Go in websocket_test.go. // +build autobahn-python package websocket_test diff --git a/websocket_test.go b/websocket_test.go index 979b092cf8b2c4dcbc1aabfb21952a447aba5ae9..ef6ae926878385da26d707386aa81e7188b8b778 100644 --- a/websocket_test.go +++ b/websocket_test.go @@ -47,10 +47,7 @@ func TestHandshake(t *testing.T) { c.Close(websocket.StatusInternalError, "") return xerrors.New("expected error regarding bad origin") } - if !strings.Contains(err.Error(), "not authorized") { - return xerrors.Errorf("expected error regarding bad origin: %+v", err) - } - return nil + return assertErrorContains(err, "not authorized") }, client: func(ctx context.Context, u string) error { h := http.Header{} @@ -62,10 +59,7 @@ func TestHandshake(t *testing.T) { c.Close(websocket.StatusInternalError, "") return xerrors.New("expected handshake failure") } - if !strings.Contains(err.Error(), "403") { - return xerrors.Errorf("expected handshake failure: %+v", err) - } - return nil + return assertErrorContains(err, "403") }, }, { @@ -123,8 +117,9 @@ func TestHandshake(t *testing.T) { if err != nil { return xerrors.Errorf("request is missing mycookie: %w", err) } - if cookie.Value != "myvalue" { - return xerrors.Errorf("expected %q but got %q", "myvalue", cookie.Value) + err = assertEqualf("myvalue", cookie.Value, "unexpected cookie value") + if err != nil { + return err } c, err := websocket.Accept(w, r, nil) if err != nil {