payment quotation v2 + payment orchestration v2 draft
This commit is contained in:
65
api/payments/storage/model/rail_operations_test.go
Normal file
65
api/payments/storage/model/rail_operations_test.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package model
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNormalizeRailOperations(t *testing.T) {
|
||||
ops := NormalizeRailOperations([]RailOperation{
|
||||
"send",
|
||||
"SEND",
|
||||
" external_credit ",
|
||||
"unknown",
|
||||
"",
|
||||
})
|
||||
if len(ops) != 2 {
|
||||
t.Fatalf("unexpected operations count: got=%d want=2", len(ops))
|
||||
}
|
||||
if ops[0] != RailOperationSend {
|
||||
t.Fatalf("unexpected first operation: got=%q want=%q", ops[0], RailOperationSend)
|
||||
}
|
||||
if ops[1] != RailOperationExternalCredit {
|
||||
t.Fatalf("unexpected second operation: got=%q want=%q", ops[1], RailOperationExternalCredit)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasRailOperation(t *testing.T) {
|
||||
ops := []RailOperation{RailOperationSend, RailOperationExternalCredit}
|
||||
if !HasRailOperation(ops, RailOperationSend) {
|
||||
t.Fatalf("expected send operation to be present")
|
||||
}
|
||||
if !HasRailOperation(ops, " external_credit ") {
|
||||
t.Fatalf("expected external credit operation to be present")
|
||||
}
|
||||
if HasRailOperation(ops, RailOperationObserveConfirm) {
|
||||
t.Fatalf("did not expect observe confirm operation to be present")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRailCapabilitiesFromOperations(t *testing.T) {
|
||||
cap := RailCapabilitiesFromOperations([]RailOperation{
|
||||
RailOperationExternalDebit,
|
||||
RailOperationExternalCredit,
|
||||
RailOperationFee,
|
||||
RailOperationObserveConfirm,
|
||||
RailOperationBlock,
|
||||
RailOperationRelease,
|
||||
})
|
||||
|
||||
if !cap.CanPayIn {
|
||||
t.Fatalf("expected can pay in to be true")
|
||||
}
|
||||
if !cap.CanPayOut {
|
||||
t.Fatalf("expected can pay out to be true")
|
||||
}
|
||||
if !cap.CanSendFee {
|
||||
t.Fatalf("expected can send fee to be true")
|
||||
}
|
||||
if !cap.RequiresObserveConfirm {
|
||||
t.Fatalf("expected requires observe confirm to be true")
|
||||
}
|
||||
if !cap.CanBlock {
|
||||
t.Fatalf("expected can block to be true")
|
||||
}
|
||||
if !cap.CanRelease {
|
||||
t.Fatalf("expected can release to be true")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user