mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-25 15:10:24 +00:00
* gateio: standardise ping handlers (cherry-pick) * Add tests and expand incoming cases for proof * lint: fix and add commentary on ping delay * Update exchange/websocket/connection.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * Update exchanges/gateio/gateio_websocket.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * linter: fix * Update exchange/websocket/connection.go Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com> * fix test * glorious: insane catch --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
34 lines
672 B
Go
34 lines
672 B
Go
package gateio
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
gws "github.com/gorilla/websocket"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetWSPingHandler(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
for _, tc := range []struct {
|
|
channel string
|
|
err error
|
|
}{
|
|
{optionsPingChannel, nil},
|
|
{futuresPingChannel, nil},
|
|
{spotPingChannel, nil},
|
|
{"dong", errInvalidPingChannel},
|
|
} {
|
|
got, err := getWSPingHandler(tc.channel)
|
|
if tc.err != nil {
|
|
require.ErrorIs(t, err, tc.err)
|
|
continue
|
|
}
|
|
require.NoError(t, err)
|
|
require.Equal(t, time.Second*10, got.Delay)
|
|
require.Equal(t, gws.TextMessage, got.MessageType)
|
|
require.Contains(t, string(got.Message), tc.channel)
|
|
}
|
|
}
|