mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-19 15:10:05 +00:00
* moves everything to use single map keys, also breaks * full rollout * tests * fix a little bug * minor test fixups * Fix Key use * rm 🔑 from 🔑 struct name
73 lines
1.6 KiB
Go
73 lines
1.6 KiB
Go
package key
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/currency"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
|
)
|
|
|
|
func TestMatchesExchangeAsset(t *testing.T) {
|
|
t.Parallel()
|
|
cp := currency.NewPair(currency.BTC, currency.USD)
|
|
k := ExchangePairAsset{
|
|
Exchange: "test",
|
|
Base: cp.Base.Item,
|
|
Quote: cp.Quote.Item,
|
|
Asset: asset.Spot,
|
|
}
|
|
if !k.MatchesExchangeAsset("test", asset.Spot) {
|
|
t.Error("expected true")
|
|
}
|
|
if k.MatchesExchangeAsset("TEST", asset.Futures) {
|
|
t.Error("expected false")
|
|
}
|
|
if k.MatchesExchangeAsset("test", asset.Futures) {
|
|
t.Error("expected false")
|
|
}
|
|
if !k.MatchesExchangeAsset("TEST", asset.Spot) {
|
|
t.Error("expected true")
|
|
}
|
|
}
|
|
|
|
func TestMatchesPairAsset(t *testing.T) {
|
|
t.Parallel()
|
|
cp := currency.NewPair(currency.BTC, currency.USD)
|
|
k := ExchangePairAsset{
|
|
Base: cp.Base.Item,
|
|
Quote: cp.Quote.Item,
|
|
Asset: asset.Spot,
|
|
}
|
|
if !k.MatchesPairAsset(cp, asset.Spot) {
|
|
t.Error("expected true")
|
|
}
|
|
if k.MatchesPairAsset(cp, asset.Futures) {
|
|
t.Error("expected false")
|
|
}
|
|
if k.MatchesPairAsset(currency.EMPTYPAIR, asset.Futures) {
|
|
t.Error("expected false")
|
|
}
|
|
if k.MatchesPairAsset(currency.NewPair(currency.BTC, currency.USDT), asset.Spot) {
|
|
t.Error("expected false")
|
|
}
|
|
}
|
|
|
|
func TestMatchesExchange(t *testing.T) {
|
|
t.Parallel()
|
|
k := ExchangePairAsset{
|
|
Exchange: "test",
|
|
}
|
|
if !k.MatchesExchange("test") {
|
|
t.Error("expected true")
|
|
}
|
|
if !k.MatchesExchange("TEST") {
|
|
t.Error("expected true")
|
|
}
|
|
if k.MatchesExchange("tèst") {
|
|
t.Error("expected false")
|
|
}
|
|
if k.MatchesExchange("") {
|
|
t.Error("expected false")
|
|
}
|
|
}
|