mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* exchanges/sharedtestvalues: implement new functions to handle test skipping and announcements for standardising. * exchanges: fin test impl. * linter: fixes * exchange_template: fix test * allocate so it doesn't make a panic at the disco * glorious: nits * glorious: nits * Update exchanges/sharedtestvalues/sharedtestvalues.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * Update exchanges/sharedtestvalues/sharedtestvalues.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * glorious: nits * linter: fix * linter: shhhh --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
58 lines
1.3 KiB
Cheetah
58 lines
1.3 KiB
Cheetah
{{define "test"}}
|
|
package {{.Name}}
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/config"
|
|
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
|
)
|
|
|
|
// Please supply your own keys here to do authenticated endpoint testing
|
|
const (
|
|
apiKey = ""
|
|
apiSecret = ""
|
|
canManipulateRealOrders = false
|
|
)
|
|
|
|
var {{.Variable}} = &{{.CapitalName}}{}
|
|
|
|
func TestMain(m *testing.M) {
|
|
{{.Variable}}.SetDefaults()
|
|
cfg := config.GetConfig()
|
|
err := cfg.LoadConfig("../../testdata/configtest.json", true)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
exchCfg, err := cfg.GetExchangeConfig("{{.CapitalName}}")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
exchCfg.API.AuthenticatedSupport = true
|
|
{{ if .WS }} exchCfg.API.AuthenticatedWebsocketSupport = true {{ end }}
|
|
exchCfg.API.Credentials.Key = apiKey
|
|
exchCfg.API.Credentials.Secret = apiSecret
|
|
|
|
err = {{.Variable}}.Setup(exchCfg)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
// Ensures that this exchange package is compatible with IBotExchange
|
|
func TestInterface(t *testing.T) {
|
|
var e exchange.IBotExchange
|
|
if e = new({{.CapitalName}}); e == nil {
|
|
t.Fatal("unable to allocate exchange")
|
|
}
|
|
}
|
|
|
|
// Implement tests for API endpoints below
|
|
{{end}}
|