mirror of
https://github.com/luxfi/bank.git
synced 2026-10-30 17:02:07 +00:00
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]>
52 lines
1.3 KiB
Go
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)
|
|
}
|
|
}
|
|
}
|