Skip to content

Commit

Permalink
fix: skip test when run in github action
Browse files Browse the repository at this point in the history
  • Loading branch information
zenixls2 committed Mar 12, 2024
1 parent d4eef3e commit 8268ac1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
go-version:
- "1.20"
env:
GITHUB_CI: true
MYSQL_DATABASE: bbgo
MYSQL_USER: "root"
MYSQL_PASSWORD: "root" # pragma: allowlist secret
Expand Down
11 changes: 9 additions & 2 deletions pkg/exchange/binance/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package binance

import (
"context"
"os"
"strings"
"testing"

Expand All @@ -22,6 +23,12 @@ func Test_new(t *testing.T) {
assert.NotEmpty(t, ex)
ctx := context.Background()
ticker, err := ex.QueryTicker(ctx, "btcusdt")
assert.NotEmpty(t, ticker)
assert.NoError(t, err)
if len(os.Getenv("GITHUB_CI")) > 0 {
// Github action runs in the US, and therefore binance api is not accessible
assert.Empty(t, ticker)
assert.Error(t, err)
} else {
assert.NotEmpty(t, ticker)
assert.NoError(t, err)
}
}

0 comments on commit 8268ac1

Please sign in to comment.