fix(supply-api): restore package create insert contract
This commit is contained in:
@@ -36,7 +36,7 @@ func (r *PackageRepository) Create(ctx context.Context, pkg *domain.Package, req
|
||||
request_id
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21,
|
||||
$22, $23, $24, $25, $26, $27, $28
|
||||
$22, $23, $24, $25, $26, $27, $28, $29
|
||||
)
|
||||
RETURNING id, created_at, updated_at
|
||||
`
|
||||
|
||||
@@ -6,6 +6,9 @@ package repository
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"lijiaoqiao/supply-api/internal/domain"
|
||||
)
|
||||
|
||||
func TestPackageRepositorySchemaContract(t *testing.T) {
|
||||
@@ -41,7 +44,37 @@ func TestPackageRepository_Create_Integration(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
requireTable(t, pool, "supply_packages")
|
||||
repo := NewPackageRepository(pool)
|
||||
pkg := &domain.Package{
|
||||
SupplierID: 1001,
|
||||
AccountID: 2001,
|
||||
Platform: "openai",
|
||||
Model: "gpt-4.1-mini",
|
||||
TotalQuota: 10000,
|
||||
AvailableQuota: 10000,
|
||||
SoldQuota: 0,
|
||||
ReservedQuota: 0,
|
||||
PricePer1MInput: 0.25,
|
||||
PricePer1MOutput: 0.75,
|
||||
MinPurchase: 100,
|
||||
StartAt: time.Date(2026, 4, 20, 0, 0, 0, 0, time.UTC),
|
||||
EndAt: time.Date(2026, 5, 20, 0, 0, 0, 0, time.UTC),
|
||||
ValidDays: 30,
|
||||
Status: domain.PackageStatusDraft,
|
||||
MaxConcurrent: 5,
|
||||
RateLimitRPM: 60,
|
||||
TotalOrders: 0,
|
||||
TotalRevenue: 0,
|
||||
Rating: 0,
|
||||
RatingCount: 0,
|
||||
}
|
||||
|
||||
if err := repo.Create(context.Background(), pkg, "req-pkg-create-int", "trace-pkg-create-int"); err != nil {
|
||||
t.Fatalf("create package failed: %v", err)
|
||||
}
|
||||
if pkg.ID == 0 {
|
||||
t.Fatal("expected created package id")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackageRepository_GetByID_Integration(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user