feat(server): Redeem 换芯 GuardedRedeem——grant 回调同事务复刻订阅叠加+双审计(#codes-lib)
This commit is contained in:
@@ -3,7 +3,9 @@ package codes_test
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/wangjia/pangolin/server/internal/config"
|
||||
"github.com/wangjia/pangolin/server/internal/store"
|
||||
@@ -28,3 +30,16 @@ func openMigratedSQLite(t *testing.T) *sql.DB {
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
// seedUser inserts a minimal `users` row so redeem tests can satisfy the
|
||||
// subscriptions/audit_log foreign keys.
|
||||
func seedUser(t *testing.T, db *sql.DB, id int64) {
|
||||
t.Helper()
|
||||
if _, err := db.Exec(
|
||||
`INSERT INTO users (id, uuid, email, pw_hash, dp_uuid, status, created_at)
|
||||
VALUES (?, ?, ?, 'x', ?, 'active', ?)`,
|
||||
id, fmt.Sprintf("u-%d", id), fmt.Sprintf("u%d@example.com", id), fmt.Sprintf("dp-%d", id),
|
||||
time.Now().UTC()); err != nil {
|
||||
t.Fatalf("seed user: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user