mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 23:16:48 +00:00
* Test: Internal exchange coverage * Tests: Rename exchange.TestInstance to Setup This package function is either going to be imported and used as just exchange.Setup, or more likely testexch.Setup. This removes the Stutter of having internal/testing/exchange.TestInstance which is implicit given the package path
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package exchange
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gorilla/websocket"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/thrasher-corp/gocryptotrader/config"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/binance"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
|
|
)
|
|
|
|
// TestSetup exercises Setup
|
|
func TestSetup(t *testing.T) {
|
|
b := new(binance.Binance)
|
|
require.NoError(t, Setup(b), "Setup must not error")
|
|
assert.NotNil(t, b.Websocket, "Websocket should not be nil after Setup")
|
|
|
|
e := new(sharedtestvalues.CustomEx)
|
|
assert.ErrorIs(t, Setup(e), config.ErrExchangeNotFound, "Setup should error correctly on a missing exchange")
|
|
}
|
|
|
|
// TestMockHTTPInstance exercises MockHTTPInstance
|
|
func TestMockHTTPInstance(t *testing.T) {
|
|
b := new(binance.Binance)
|
|
require.NoError(t, Setup(b), "Test exchange Setup must not error")
|
|
require.NoError(t, MockHTTPInstance(b), "MockHTTPInstance must not error")
|
|
}
|
|
|
|
// TestMockWsInstance exercises MockWsInstance
|
|
func TestMockWsInstance(t *testing.T) {
|
|
b := MockWsInstance[binance.Binance](t, CurryWsMockUpgrader(t, func(_ []byte, _ *websocket.Conn) error { return nil }))
|
|
require.NotNil(t, b, "MockWsInstance must not be nil")
|
|
}
|