57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
|
|
//go:build llm_script
|
|||
|
|
|
|||
|
|
package main
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"bytes"
|
|||
|
|
"path/filepath"
|
|||
|
|
"strings"
|
|||
|
|
"testing"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
func TestBuildManualSubscriptionRows(t *testing.T) {
|
|||
|
|
envelope, err := loadManualSubscriptionSeed(filepath.Join("..", "seeds", "subscription_plan_manual_seed.json"))
|
|||
|
|
if err != nil {
|
|||
|
|
t.Fatalf("loadManualSubscriptionSeed 失败: %v", err)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
rows, err := buildManualSubscriptionRows(envelope)
|
|||
|
|
if err != nil {
|
|||
|
|
t.Fatalf("buildManualSubscriptionRows 失败: %v", err)
|
|||
|
|
}
|
|||
|
|
if len(rows) != 3 {
|
|||
|
|
t.Fatalf("期望 3 条套餐记录,实际 %d", len(rows))
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if rows[0].PlanCode != "minimax-token-plan-starter" {
|
|||
|
|
t.Fatalf("首条 planCode 错误: %q", rows[0].PlanCode)
|
|||
|
|
}
|
|||
|
|
if rows[len(rows)-1].PlanCode != "minimax-token-plan-max" {
|
|||
|
|
t.Fatalf("末条 planCode 错误: %q", rows[len(rows)-1].PlanCode)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func TestRunManualSubscriptionImportDryRunPrintsSummary(t *testing.T) {
|
|||
|
|
var out bytes.Buffer
|
|||
|
|
err := runManualSubscriptionImport(manualSubscriptionImportConfig{
|
|||
|
|
SeedPath: filepath.Join("..", "seeds", "subscription_plan_manual_seed.json"),
|
|||
|
|
DryRun: true,
|
|||
|
|
}, nil, &out)
|
|||
|
|
if err != nil {
|
|||
|
|
t.Fatalf("runManualSubscriptionImport 失败: %v", err)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
output := out.String()
|
|||
|
|
for _, want := range []string{
|
|||
|
|
"source=manual-subscription-seed",
|
|||
|
|
"rows=3",
|
|||
|
|
"MiniMax:3",
|
|||
|
|
"token_plan:3",
|
|||
|
|
"dry_run=true",
|
|||
|
|
} {
|
|||
|
|
if !strings.Contains(output, want) {
|
|||
|
|
t.Fatalf("输出缺少 %q,实际: %q", want, output)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|