34 lines
800 B
Go
34 lines
800 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/Wei-Shaw/sub2api/internal/payment"
|
|
)
|
|
|
|
func TestUsesOfficialWxpayVisibleMethodDerivesFromEnabledProviderInstance(t *testing.T) {
|
|
ctx := context.Background()
|
|
client := newPaymentConfigServiceTestClient(t)
|
|
|
|
_, err := client.PaymentProviderInstance.Create().
|
|
SetProviderKey(payment.TypeWxpay).
|
|
SetName("Official WeChat").
|
|
SetConfig("{}").
|
|
SetSupportedTypes("wxpay").
|
|
SetEnabled(true).
|
|
SetSortOrder(1).
|
|
Save(ctx)
|
|
if err != nil {
|
|
t.Fatalf("create official wxpay instance: %v", err)
|
|
}
|
|
|
|
svc := &PaymentService{
|
|
configService: &PaymentConfigService{entClient: client},
|
|
}
|
|
|
|
if !svc.usesOfficialWxpayVisibleMethod(ctx) {
|
|
t.Fatal("expected official wxpay visible method to be detected from enabled provider instance")
|
|
}
|
|
}
|