Yimaru-BackEnd/internal/domain/payment_test.go
Yared Yemane 7a4253edf4 Add explicit payment provider selection for subscriptions.
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>
2026-05-26 04:18:24 -07:00

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)
}
})
}
}