Files
gocryptotrader/cmd/exchange_template/test_file.tmpl
Ryan O'Hara-Reid b20cf75d13 sharedtestvalues: Add helper functions and implement throughout exchange tests (#1163)
* 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>
2023-04-28 13:05:42 +10:00

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}}