mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-19 15:10:05 +00:00
* Various bug fixes * Deadlink, cleanup plus bug fixes * Various Kraken fixes * Add convert func for decimal unix timestamps * Convert all test times to UTC * Kraken: Make assets a pointer to prevent excessive copying * Docker slash fix * Address nits plus bump ITBit last checked pairs timestamp * Set pairs to enabled pairs when getting active orders * Use asset translator for UpdateAccountInfo and more checks for the exchange template tool * Address MadCozBadd's nits * Make exchange var 2 chars * Make program more user friendly * Project wide comment checks and exchName check * Fix Huobi indexing bug and use correct pair formatting * Address nits + readme change
75 lines
1.5 KiB
Go
75 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/config"
|
|
)
|
|
|
|
func TestCheckExchangeName(t *testing.T) {
|
|
tester := []struct {
|
|
Name string
|
|
ErrExpected error
|
|
}{
|
|
{
|
|
Name: "test exch",
|
|
ErrExpected: errInvalidExchangeName,
|
|
},
|
|
{
|
|
ErrExpected: errInvalidExchangeName,
|
|
},
|
|
{
|
|
Name: " ",
|
|
ErrExpected: errInvalidExchangeName,
|
|
},
|
|
{
|
|
Name: "m",
|
|
ErrExpected: errInvalidExchangeName,
|
|
},
|
|
{
|
|
Name: "mu",
|
|
ErrExpected: errInvalidExchangeName,
|
|
},
|
|
{
|
|
Name: "testexch",
|
|
},
|
|
}
|
|
|
|
for x := range tester {
|
|
if r := checkExchangeName(tester[x].Name); r != tester[x].ErrExpected {
|
|
t.Errorf("test: %d unexpected result", x)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestNewExchange(t *testing.T) {
|
|
testExchangeName := "testexch"
|
|
testExchangeDir := filepath.Join(targetPath, testExchangeName)
|
|
|
|
if err := makeExchange(&exchange{
|
|
Name: testExchangeName,
|
|
REST: true,
|
|
WS: true,
|
|
}); err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
if err := os.RemoveAll(testExchangeDir); err != nil {
|
|
t.Errorf("unable to remove dir: %s, manual removal required", err)
|
|
}
|
|
|
|
cfg := config.GetConfig()
|
|
if err := cfg.LoadConfig(exchangeConfigPath, true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if success := cfg.RemoveExchange(testExchangeName); !success {
|
|
t.Fatalf("unable to remove exchange config for %s, manual removal required\n",
|
|
testExchangeName)
|
|
}
|
|
if err := cfg.SaveConfig(exchangeConfigPath, false); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|