feat(server): 到账通知四接缝(邀请注册/首充/TG/购买开通)——与发放同事务零孤儿
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/wangjia/pangolin/server/internal/notices"
|
||||
)
|
||||
|
||||
func TestSettle_InsertsPurchaseNotice(t *testing.T) {
|
||||
h, db, st := newWebhookRig(t)
|
||||
h.SetNoticer(notices.NewStore(db))
|
||||
ctx := context.Background()
|
||||
if err := st.Insert(ctx, 1, "uuid-1", "pro_month", "pay-notice-1", "crypto", 4990000, "USDT"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
w := deliver(t, h, succeededPayload("pay-notice-1", "pro_month"))
|
||||
if w.Code != 200 {
|
||||
t.Fatalf("code=%d body=%s", w.Code, w.Body)
|
||||
}
|
||||
var n int
|
||||
if err := db.QueryRow(`SELECT COUNT(*) FROM notices WHERE type='reward' AND user_id=1`).Scan(&n); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n != 1 {
|
||||
t.Fatalf("购买开通应插入一条到账通知, got %d", n)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user