Files
bank/hooks/rails_test.go
zeekayandHanzo Dev 9b28d8ca64 bank: cover rail fees, status mappers, CC conversion, freeze audit (70% -> 73%)
Table tests for the pure mappers — RailFee (every rail + default),
mapCCStatus, mapIFXStatus (every case + default). The CC conversion
webhook reconciles (completing the payment/conversion/IFX webhook set),
and freezing an account is proven to write an immutable audit-log entry.
Total ./... coverage 69.9% -> 73.1%.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-22 16:41:20 -07:00

52 lines
1.3 KiB
Go

package hooks
import "testing"
func TestRailFee(t *testing.T) {
cases := map[PaymentRail]int64{
RailSEPA: 500,
RailSEPAInst: 1000,
RailFPS: 0,
RailACH: 0,
RailWire: 2500,
RailSWIFT: 3500,
RailInterac: 150,
RailInternal: 0,
PaymentRail("unknown"): 2500, // default is the wire fee
}
for rail, want := range cases {
if got := RailFee(rail); got != want {
t.Errorf("RailFee(%q) = %d, want %d", rail, got, want)
}
}
}
func TestMapCCStatus(t *testing.T) {
cases := map[string]string{
"ready_to_send": "processing",
"submitted": "processing",
"completed": "completed",
"failed": "failed",
"cancelled": "cancelled",
"weird": "pending", // unknown maps to pending (no state change)
}
for in, want := range cases {
if got := mapCCStatus(in); got != want {
t.Errorf("mapCCStatus(%q) = %q, want %q", in, got, want)
}
}
}
func TestMapIFXStatus(t *testing.T) {
cases := map[string]string{
"settled": "completed",
"rejected": "failed",
"anything": "processing",
}
for in, want := range cases {
if got := mapIFXStatus(in); got != want {
t.Errorf("mapIFXStatus(%q) = %q, want %q", in, got, want)
}
}
}