64 lines
1.8 KiB
Go
64 lines
1.8 KiB
Go
package discovery
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeRailOperations(t *testing.T) {
|
|
got := NormalizeRailOperations([]string{
|
|
"send",
|
|
"payout.crypto",
|
|
"observe.confirm",
|
|
"external.credit",
|
|
"fx.convert",
|
|
"unknown",
|
|
})
|
|
|
|
want := []string{
|
|
RailOperationSend,
|
|
RailOperationExternalCredit,
|
|
RailOperationObserveConfirm,
|
|
RailOperationFXConvert,
|
|
}
|
|
if len(got) != len(want) {
|
|
t.Fatalf("unexpected operations count: got=%d want=%d", len(got), len(want))
|
|
}
|
|
for i := range want {
|
|
if got[i] != want[i] {
|
|
t.Fatalf("unexpected operation[%d]: got=%q want=%q", i, got[i], want[i])
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestExpandRailOperationLegacyAliases(t *testing.T) {
|
|
got := ExpandRailOperation("payout.fiat")
|
|
if len(got) != 2 {
|
|
t.Fatalf("unexpected operations count: got=%d want=2", len(got))
|
|
}
|
|
if got[0] != RailOperationExternalCredit {
|
|
t.Fatalf("unexpected first operation: got=%q want=%q", got[0], RailOperationExternalCredit)
|
|
}
|
|
if got[1] != RailOperationSend {
|
|
t.Fatalf("unexpected second operation: got=%q want=%q", got[1], RailOperationSend)
|
|
}
|
|
}
|
|
|
|
func TestIsKnownRail(t *testing.T) {
|
|
if !IsKnownRail("crypto") {
|
|
t.Fatalf("expected crypto rail to be known")
|
|
}
|
|
if IsKnownRail("telegram") {
|
|
t.Fatalf("did not expect telegram rail to be known")
|
|
}
|
|
}
|
|
|
|
func TestNormalizeRailAliases(t *testing.T) {
|
|
if got := NormalizeRail("provider_settlement"); got != RailProviderSettlement {
|
|
t.Fatalf("provider_settlement alias mismatch: got=%q want=%q", got, RailProviderSettlement)
|
|
}
|
|
if got := NormalizeRail("card_payout"); got != RailCardPayout {
|
|
t.Fatalf("card_payout alias mismatch: got=%q want=%q", got, RailCardPayout)
|
|
}
|
|
if got := NormalizeRail("RAIL_SETTLEMENT"); got != RailProviderSettlement {
|
|
t.Fatalf("RAIL_SETTLEMENT alias mismatch: got=%q want=%q", got, RailProviderSettlement)
|
|
}
|
|
}
|