bbgo_origin/pkg/exchange/bybit/bybitapi/client_test.go

49 lines
1.0 KiB
Go

package bybitapi
import (
"context"
"os"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
"github.com/c9s/bbgo/pkg/testutil"
)
func getTestClientOrSkip(t *testing.T) *RestClient {
if b, _ := strconv.ParseBool(os.Getenv("CI")); b {
t.Skip("skip test for CI")
}
key, secret, ok := testutil.IntegrationTestConfigured(t, "BYBIT")
if !ok {
t.Skip("BYBIT_* env vars are not configured")
return nil
}
client, err := NewClient()
assert.NoError(t, err)
client.Auth(key, secret)
return client
}
func TestClient(t *testing.T) {
client := getTestClientOrSkip(t)
ctx := context.Background()
t.Run("GetAccountInfoRequest", func(t *testing.T) {
req := client.NewGetAccountRequest()
accountInfo, err := req.Do(ctx)
assert.NoError(t, err)
t.Logf("accountInfo: %+v", accountInfo)
})
t.Run("GetInstrumentsInfoRequest", func(t *testing.T) {
req := client.NewGetInstrumentsInfoRequest()
instrumentsInfo, err := req.Do(ctx)
assert.NoError(t, err)
t.Logf("instrumentsInfo: %+v", instrumentsInfo)
})
}