新增支付配置备份导入
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package paymentconfig
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestImportCreateRequestKeepsOnlyOneActiveConfig(t *testing.T) {
|
||||
configs := []ConfigDTO{
|
||||
{Provider: "lakala", MerchantID: "M1", Status: "active", IsDefault: true},
|
||||
{Provider: "leshua", MerchantID: "M2", Status: "active", IsDefault: false},
|
||||
}
|
||||
activeKey := backupActiveKey(configs)
|
||||
|
||||
first := importCreateRequest(configs[0], activeKey)
|
||||
second := importCreateRequest(configs[1], activeKey)
|
||||
|
||||
if first.Status != "active" || !first.IsDefault {
|
||||
t.Fatalf("first config status/default = %s/%v, want active/true", first.Status, first.IsDefault)
|
||||
}
|
||||
if second.Status != "disabled" || second.IsDefault {
|
||||
t.Fatalf("second config status/default = %s/%v, want disabled/false", second.Status, second.IsDefault)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImportCreateRequestPreservesTestingConfig(t *testing.T) {
|
||||
cfg := ConfigDTO{
|
||||
Provider: "lakala",
|
||||
MerchantID: "M1",
|
||||
Status: "testing",
|
||||
}
|
||||
|
||||
req := importCreateRequest(cfg, "")
|
||||
|
||||
if req.Status != "testing" || req.IsDefault {
|
||||
t.Fatalf("status/default = %s/%v, want testing/false", req.Status, req.IsDefault)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user