mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-21 15:10:12 +00:00
* Adds mock testing to ZB
* STEALS improved time validation code from the original STOLEN validation code :D
* Mini fixes from review
* happy fun comment stealing
* Moves the loop checker earlier to ensure no double appendages
* Fixes sneaky test
* Fixes the important part where mock tests work instead of live tests
* Skips authenticated endpoints for mock testing.
* lint
* Updates candle wrapper functions to respect design
* basic linting fix
* Reverts configtest.json, updates readme to be way better, adds coverage to validateCandlesRequest
* Tiniest grammatical fix
* Fixes more outdated code references
* Closing out a high
* Fixes spacing
* Replaces all instances of 4 spaces in tmpl files with a tab
* fixes spacing and tab related readme issues once and for all 🤞
* tidy
* indentation violation identification situation
62 lines
1.3 KiB
Cheetah
62 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")
|
|
}
|
|
}
|
|
|
|
func areTestAPIKeysSet() bool {
|
|
return {{.Variable}}.ValidateAPICredentials()
|
|
}
|
|
|
|
// Implement tests for API endpoints below
|
|
{{end}}
|