forked from niuniu/llm-intelligence
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:
61
scripts/import_huawei_package_test.go
Normal file
61
scripts/import_huawei_package_test.go
Normal file
@@ -0,0 +1,61 @@
|
||||
//go:build llm_script
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseHuaweiPackageCatalogBuildsPlans(t *testing.T) {
|
||||
raw, err := os.ReadFile(filepath.Join("testdata", "huawei_package_plan_sample.txt"))
|
||||
if err != nil {
|
||||
t.Fatalf("读取 fixture 失败: %v", err)
|
||||
}
|
||||
|
||||
plans, err := parseHuaweiPackageCatalog(string(raw))
|
||||
if err != nil {
|
||||
t.Fatalf("parseHuaweiPackageCatalog 返回错误: %v", err)
|
||||
}
|
||||
if len(plans) != 8 {
|
||||
t.Fatalf("期望 8 条华为套餐包记录,实际 %d", len(plans))
|
||||
}
|
||||
if plans[0].PlanCode != "huawei-deepseek-v3-1-package-100w-1m" {
|
||||
t.Fatalf("首条 planCode 错误: %q", plans[0].PlanCode)
|
||||
}
|
||||
if plans[4].PlanCode != "huawei-deepseek-v3-2-package-100w-1m" {
|
||||
t.Fatalf("DeepSeek-V3.2 首条 planCode 错误: %q", plans[4].PlanCode)
|
||||
}
|
||||
if plans[7].ListPrice != 2199 {
|
||||
t.Fatalf("DeepSeek-V3.2 10亿套餐价格错误: %v", plans[7].ListPrice)
|
||||
}
|
||||
if plans[7].PlanFamily != "package_plan" {
|
||||
t.Fatalf("planFamily 错误: %q", plans[7].PlanFamily)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunHuaweiPackageImportDryRunPrintsSummary(t *testing.T) {
|
||||
var out bytes.Buffer
|
||||
err := runHuaweiPackageImport(huaweiPackageImportConfig{
|
||||
Fixture: filepath.Join("testdata", "huawei_package_plan_sample.txt"),
|
||||
DryRun: true,
|
||||
}, nil, &out)
|
||||
if err != nil {
|
||||
t.Fatalf("runHuaweiPackageImport 返回错误: %v", err)
|
||||
}
|
||||
output := out.String()
|
||||
for _, want := range []string{
|
||||
"source=huawei-package-import",
|
||||
"plans=8",
|
||||
"provider=Huawei",
|
||||
"operator=Huawei Cloud",
|
||||
"dry_run=true",
|
||||
} {
|
||||
if !strings.Contains(output, want) {
|
||||
t.Fatalf("输出缺少 %q,实际: %q", want, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user