Documentation ¶
Index ¶
- func CurryWsMockUpgrader(tb testing.TB, wsHandler WsMockFunc) http.HandlerFunc
- func MockHTTPInstance(e exchange.IBotExchange) error
- func MockWsInstance[T any, PT interface{ ... }](tb testing.TB, h http.HandlerFunc) *T
- func Setup(e exchange.IBotExchange) error
- func SetupWs(tb testing.TB, e exchange.IBotExchange)
- func UpdatePairsOnce(tb testing.TB, e exchange.IBotExchange)
- func WsMockUpgrader(tb testing.TB, w http.ResponseWriter, r *http.Request, wsHandler WsMockFunc)
- type WsMockFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurryWsMockUpgrader ¶
func CurryWsMockUpgrader(tb testing.TB, wsHandler WsMockFunc) http.HandlerFunc
CurryWsMockUpgrader curries a WsMockUpgrader with a testing.TB and a mock func bridging the gap between information known before the Server is created and during a request
func MockHTTPInstance ¶
func MockHTTPInstance(e exchange.IBotExchange) error
MockHTTPInstance takes an existing Exchange instance and attaches it to a new http server It is expected to be run once, since http requests do not often tangle with each other
func MockWsInstance ¶
func MockWsInstance[T any, PT interface { *T exchange.IBotExchange }](tb testing.TB, h http.HandlerFunc) *T
MockWsInstance creates a new Exchange instance with a mock websocket instance and HTTP server It accepts an exchange package type argument and a http.HandlerFunc See CurryWsMockUpgrader for a convenient way to curry t and a ws mock function It is expected to be run from any WS tests which need a specific response function No default subscriptions will be run since they disrupt unit tests
func Setup ¶
func Setup(e exchange.IBotExchange) error
Setup takes an empty exchange instance and loads config for it from testdata/configtest and connects a NewTestWebsocket
func SetupWs ¶
func SetupWs(tb testing.TB, e exchange.IBotExchange)
SetupWs is a helper function to connect both auth and normal websockets It will skip the test if websockets are not enabled It's up to the test to skip if it requires creds, though
func UpdatePairsOnce ¶
func UpdatePairsOnce(tb testing.TB, e exchange.IBotExchange)
UpdatePairsOnce ensures pairs are only updated once in parallel tests
func WsMockUpgrader ¶
func WsMockUpgrader(tb testing.TB, w http.ResponseWriter, r *http.Request, wsHandler WsMockFunc)
WsMockUpgrader handles upgrading an initial HTTP request to WS, and then runs a for loop calling the mock func on each input