Files
pangolin/server/internal/pay/webhook_notice_sqlite_test.go
T

29 lines
740 B
Go

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)
}
}