36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
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)
|
|
}
|
|
}
|