Files
llm-intelligence/scripts/import_minimax_subscription_test.go
phamnazage-jpg 958245537a feat(imports): add real pricing and subscription collectors
Add plan catalog and subscription schema support, seed baselines, and real importers for core domestic subscriptions plus stable official pricing sources.

This commit also hardens the shared fetch layers so the importers can support live collection and database writes instead of relying on manual placeholders alone.
2026-05-15 22:32:57 +08:00

75 lines
2.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build llm_script
package main
import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"
)
func TestParseMinimaxTokenPlansBuildsRecords(t *testing.T) {
raw, err := os.ReadFile(filepath.Join("testdata", "minimax_token_plan_sample.txt"))
if err != nil {
t.Fatalf("读取 MiniMax fixture 失败: %v", err)
}
plans, err := parseMinimaxTokenPlans(string(raw))
if err != nil {
t.Fatalf("parseMinimaxTokenPlans 失败: %v", err)
}
if len(plans) != 12 {
t.Fatalf("期望 12 条 MiniMax 套餐记录,实际 %d", len(plans))
}
if plans[0].PlanCode != "minimax-token-plan-starter" {
t.Fatalf("首条 planCode 错误: %q", plans[0].PlanCode)
}
if plans[0].ListPrice != 10 || plans[0].QuotaValue != 1500 {
t.Fatalf("Starter 月度套餐解析错误: %+v", plans[0])
}
if plans[5].PlanCode != "minimax-token-plan-ultra-highspeed" {
t.Fatalf("高速月度套餐 planCode 错误: %q", plans[5].PlanCode)
}
if plans[5].ListPrice != 150 || plans[5].QuotaValue != 30000 {
t.Fatalf("高速月度套餐解析错误: %+v", plans[5])
}
if plans[len(plans)-1].PlanCode != "minimax-token-plan-ultra-highspeed-yearly" {
t.Fatalf("末条 planCode 错误: %q", plans[len(plans)-1].PlanCode)
}
if plans[len(plans)-1].ListPrice != 1500 || plans[len(plans)-1].QuotaValue != 30000 {
t.Fatalf("高速年度套餐解析错误: %+v", plans[len(plans)-1])
}
if !strings.Contains(plans[0].Notes, "Speech 2.8") {
t.Fatalf("标准套餐备注缺少附带配额说明: %q", plans[0].Notes)
}
if !strings.Contains(plans[5].Notes, "高速版覆盖") {
t.Fatalf("高速套餐备注缺少高速版说明: %q", plans[5].Notes)
}
}
func TestRunMinimaxSubscriptionImportDryRunPrintsSummary(t *testing.T) {
var out bytes.Buffer
err := runMinimaxSubscriptionImport(minimaxSubscriptionImportConfig{
Fixture: filepath.Join("testdata", "minimax_token_plan_sample.txt"),
DryRun: true,
}, nil, &out)
if err != nil {
t.Fatalf("runMinimaxSubscriptionImport 失败: %v", err)
}
output := out.String()
for _, want := range []string{
"source=minimax-subscription-import",
"plans=12",
"provider=MiniMax",
"operator=MiniMax",
"dry_run=true",
} {
if !strings.Contains(output, want) {
t.Fatalf("输出缺少 %q实际: %q", want, output)
}
}
}