支付相关
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"kra/internal/biz"
|
||||
)
|
||||
|
||||
func TestMigrateSeedsPaymentProviders(t *testing.T) {
|
||||
db, err := openWithDriver("sqlite", "file:"+t.Name()+"?mode=memory&cache=shared")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = migrateAll(db); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var count int64
|
||||
if err = db.Model(&integrationConfigPO{}).Where("kind = ?", integrationKindPayment).Count(&count).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if count != int64(len(biz.SupportedPaymentProviders)) {
|
||||
t.Fatalf("payment providers = %d", count)
|
||||
}
|
||||
if !db.Migrator().HasTable("pay_orders") {
|
||||
t.Fatal("payment migration must create pay_orders")
|
||||
}
|
||||
if db.Migrator().HasTable("pay_callback_events") {
|
||||
t.Fatal("payment migration must not create pay_callback_events")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPaymentSecretMaskAndMerge(t *testing.T) {
|
||||
values := map[string]any{"app_id": "a", "private_key": "private", "nested": map[string]any{"api_v3_key": "key"}}
|
||||
maskPaymentSecrets(values)
|
||||
if values["private_key"] != "******" || values["nested"].(map[string]any)["api_v3_key"] != "******" {
|
||||
t.Fatalf("not masked: %#v", values)
|
||||
}
|
||||
mergePaymentSecrets(values, map[string]any{"private_key": "private", "nested": map[string]any{"api_v3_key": "key"}})
|
||||
if values["private_key"] != "private" || values["nested"].(map[string]any)["api_v3_key"] != "key" {
|
||||
t.Fatalf("not merged: %#v", values)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user