mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-24 07:45:15 +00:00
49 lines
1.0 KiB
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)
|
|
})
|
|
}
|