fixed rail & operation names

This commit is contained in:
Stephan D
2026-02-27 02:33:40 +01:00
parent 82cf91e703
commit 747153bdbf
73 changed files with 877 additions and 667 deletions

View File

@@ -5,17 +5,17 @@ import "testing"
func TestNormalizeRailOperations(t *testing.T) {
got := NormalizeRailOperations([]string{
"send",
"payout.crypto",
"observe.confirm",
"external.credit",
"fx.convert",
"payout.crypto",
"unknown",
})
want := []string{
RailOperationSend,
RailOperationExternalCredit,
RailOperationObserveConfirm,
RailOperationExternalCredit,
RailOperationFXConvert,
}
if len(got) != len(want) {
@@ -28,16 +28,9 @@ func TestNormalizeRailOperations(t *testing.T) {
}
}
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 TestExpandRailOperationRejectsLegacyAliases(t *testing.T) {
if got := ExpandRailOperation("payout.fiat"); len(got) != 0 {
t.Fatalf("expected no expansion for legacy alias, got=%v", got)
}
}
@@ -50,14 +43,65 @@ func TestIsKnownRail(t *testing.T) {
}
}
func TestNormalizeRailAliases(t *testing.T) {
if got := NormalizeRail("provider_settlement"); got != RailProviderSettlement {
t.Fatalf("provider_settlement alias mismatch: got=%q want=%q", got, RailProviderSettlement)
func TestNormalizeRailRejectsLegacyAliases(t *testing.T) {
if IsKnownRail("provider_settlement") {
t.Fatalf("did not expect provider_settlement alias to be known")
}
if got := NormalizeRail("card_payout"); got != RailCardPayout {
t.Fatalf("card_payout alias mismatch: got=%q want=%q", got, RailCardPayout)
if IsKnownRail("card_payout") {
t.Fatalf("did not expect card_payout alias to be known")
}
if got := NormalizeRail("RAIL_SETTLEMENT"); got != RailProviderSettlement {
t.Fatalf("RAIL_SETTLEMENT alias mismatch: got=%q want=%q", got, RailProviderSettlement)
if IsKnownRail("RAIL_SETTLEMENT") {
t.Fatalf("did not expect RAIL_SETTLEMENT alias to be known")
}
}
func TestGatewayOperationSetsAreCanonicalOnly(t *testing.T) {
tests := []struct {
name string
got []string
want []string
}{
{
name: "crypto rail gateway operations",
got: CryptoRailGatewayOperations(),
want: []string{
OperationBalanceRead,
OperationSend,
OperationExternalDebit,
OperationExternalCredit,
OperationFee,
OperationObserveConfirm,
},
},
{
name: "card payout rail gateway operations",
got: CardPayoutRailGatewayOperations(),
want: []string{
OperationSend,
OperationExternalCredit,
OperationObserveConfirm,
},
},
{
name: "provider settlement rail gateway operations",
got: ProviderSettlementRailGatewayOperations(),
want: []string{
OperationFXConvert,
OperationObserveConfirm,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if len(tt.got) != len(tt.want) {
t.Fatalf("unexpected operations count: got=%d want=%d", len(tt.got), len(tt.want))
}
for i := range tt.want {
if tt.got[i] != tt.want[i] {
t.Fatalf("unexpected operation[%d]: got=%q want=%q", i, tt.got[i], tt.want[i])
}
}
})
}
}