Files
gocryptotrader/common/key/key_test.go
Scott 91d699be9d maps: expansion of Key concept (#1349)
* 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
2023-10-04 10:19:41 +11:00

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