Require the client to choose CHAPA or ARIFPAY in the subscription checkout request body and route payment initiation and verification through the matching provider. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
914 B
Go
37 lines
914 B
Go
package domain
|
|
|
|
import "testing"
|
|
|
|
func TestParsePaymentProvider(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
want PaymentProvider
|
|
wantErr bool
|
|
}{
|
|
{name: "chapa uppercase", input: "CHAPA", want: PaymentProviderChapa},
|
|
{name: "chapa lowercase", input: "chapa", want: PaymentProviderChapa},
|
|
{name: "arifpay uppercase", input: "ARIFPAY", want: PaymentProviderArifPay},
|
|
{name: "arifpay underscored", input: "arif_pay", want: PaymentProviderArifPay},
|
|
{name: "invalid", input: "telebirr", wantErr: true},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := ParsePaymentProvider(tt.input)
|
|
if tt.wantErr {
|
|
if err == nil {
|
|
t.Fatal("expected error, got nil")
|
|
}
|
|
return
|
|
}
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if got != tt.want {
|
|
t.Fatalf("provider=%q, want %q", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|