Files
llm-intelligence/scripts/import_ppio_pricing_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

56 lines
1.3 KiB
Go
Raw Permalink 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 TestParsePPIOPricingCatalogBuildsRecords(t *testing.T) {
raw, err := os.ReadFile(filepath.Join("testdata", "ppio_pricing_sample.txt"))
if err != nil {
t.Fatalf("读取 fixture 失败: %v", err)
}
records, err := parsePPIOPricingCatalog(string(raw))
if err != nil {
t.Fatalf("parsePPIOPricingCatalog 返回错误: %v", err)
}
if len(records) != 5 {
t.Fatalf("期望 5 条 PPIO 价格记录,实际 %d", len(records))
}
if records[0].InputPrice != 2 {
t.Fatalf("deepseek-v3.1 输入价错误: %v", records[0].InputPrice)
}
if records[1].OutputPrice != 16 {
t.Fatalf("deepseek-r1 输出价错误: %v", records[1].OutputPrice)
}
}
func TestRunPPIOPricingImportDryRunPrintsSummary(t *testing.T) {
var out bytes.Buffer
err := runPPIOPricingImport(ppioPricingImportConfig{
URL: defaultPPIOPricingURL,
Fixture: filepath.Join("testdata", "ppio_pricing_sample.txt"),
DryRun: true,
}, nil, &out)
if err != nil {
t.Fatalf("runPPIOPricingImport 返回错误: %v", err)
}
output := out.String()
for _, want := range []string{
"source=ppio-pricing-import",
"models=5",
"operator=PPIO Model API",
"dry_run=true",
} {
if !strings.Contains(output, want) {
t.Fatalf("输出缺少 %q实际: %q", want, output)
}
}
}