//go:build llm_script package main import ( "bytes" "os" "path/filepath" "strings" "testing" ) func TestParse360PricingCatalogBuildsRecords(t *testing.T) { raw, err := os.ReadFile(filepath.Join("testdata", "platform360_pricing_sample.txt")) if err != nil { t.Fatalf("读取 fixture 失败: %v", err) } records, err := parse360PricingCatalog(string(raw)) if err != nil { t.Fatalf("parse360PricingCatalog 返回错误: %v", err) } if len(records) != 4 { t.Fatalf("期望 4 条 360 价格记录,实际 %d", len(records)) } if records[0].ModelID != "360-deepseek-deepseek-v4-flash" { t.Fatalf("首条 modelID 错误: %q", records[0].ModelID) } if records[1].ContextLength != 1000000 { t.Fatalf("第二条上下文长度错误: %d", records[1].ContextLength) } } func TestRun360PricingImportDryRunPrintsSummary(t *testing.T) { var out bytes.Buffer err := run360PricingImport(platform360PricingImportConfig{ URL: default360PricingURL, Fixture: filepath.Join("testdata", "platform360_pricing_sample.txt"), DryRun: true, }, nil, &out) if err != nil { t.Fatalf("run360PricingImport 返回错误: %v", err) } output := out.String() for _, want := range []string{ "source=360-pricing-import", "models=4", "operator=360 ZhiNao", "dry_run=true", } { if !strings.Contains(output, want) { t.Fatalf("输出缺少 %q,实际: %q", want, output) } } }