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.
This commit is contained in:
phamnazage-jpg
2026-05-15 22:32:57 +08:00
parent dd58c18fe3
commit 958245537a
91 changed files with 10474 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
//go:build llm_script
package main
import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"
)
func TestParseMobileCloudCatalogBuildsRecord(t *testing.T) {
raw, err := os.ReadFile(filepath.Join("testdata", "mobile_cloud_catalog_sample.txt"))
if err != nil {
t.Fatalf("读取 fixture 失败: %v", err)
}
records, err := parseMobileCloudCatalog(string(raw))
if err != nil {
t.Fatalf("parseMobileCloudCatalog 返回错误: %v", err)
}
if len(records) != 1 {
t.Fatalf("期望 1 条移动云目录记录,实际 %d", len(records))
}
if records[0].CatalogCode != "mobile-cloud-ai-market" {
t.Fatalf("catalogCode 错误: %q", records[0].CatalogCode)
}
if records[0].PlanStatus != "confirmed" {
t.Fatalf("planStatus 错误: %q", records[0].PlanStatus)
}
}
func TestRunMobileCloudCatalogImportDryRunPrintsSummary(t *testing.T) {
var out bytes.Buffer
err := runMobileCloudCatalogImport(catalogVerificationImportConfig{
URL: defaultMobileCloudCatalogURL,
Fixture: filepath.Join("testdata", "mobile_cloud_catalog_sample.txt"),
DryRun: true,
}, nil, &out)
if err != nil {
t.Fatalf("runMobileCloudCatalogImport 返回错误: %v", err)
}
output := out.String()
for _, want := range []string{
"source=mobile-cloud-catalog-import",
"entries=1",
"dry_run=true",
} {
if !strings.Contains(output, want) {
t.Fatalf("输出缺少 %q实际: %q", want, output)
}
}
}