Files
llm-intelligence/scripts/import_hunyuan_pricing_test.go
phamnazage-jpg 6c3569fb65
Some checks failed
CI / go-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / docker-build (push) Has been cancelled
feat(pricing): add qwen hunyuan and huawei maas payg importers
2026-05-22 12:13:54 +08:00

62 lines
1.7 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 TestParseHunyuanPricingCatalogBuildsRecords(t *testing.T) {
raw, err := os.ReadFile(filepath.Join("testdata", "hunyuan_pricing_sample.txt"))
if err != nil {
t.Fatalf("读取 fixture 失败: %v", err)
}
records, err := parseHunyuanPricingCatalog(string(raw))
if err != nil {
t.Fatalf("parseHunyuanPricingCatalog 返回错误: %v", err)
}
if len(records) != 5 {
t.Fatalf("期望 5 条混元价格记录,实际 %d", len(records))
}
if records[0].ModelID != "hunyuan-tencent-hy-2-0-think" {
t.Fatalf("首条 modelID 错误: %q", records[0].ModelID)
}
if records[2].ModelName != "Hunyuan-T1" {
t.Fatalf("第三条模型名错误: %q", records[2].ModelName)
}
if records[3].InputPrice != 0.8 || records[3].OutputPrice != 2 {
t.Fatalf("Hunyuan-TurboS 定价错误: %v / %v", records[3].InputPrice, records[3].OutputPrice)
}
if records[4].ProviderName != "Tencent" {
t.Fatalf("provider 错误: %q", records[4].ProviderName)
}
}
func TestRunHunyuanPricingImportDryRunPrintsSummary(t *testing.T) {
var out bytes.Buffer
err := runHunyuanPricingImport(hunyuanPricingImportConfig{
URL: defaultHunyuanPricingURL,
Fixture: filepath.Join("testdata", "hunyuan_pricing_sample.txt"),
DryRun: true,
}, nil, &out)
if err != nil {
t.Fatalf("runHunyuanPricingImport 返回错误: %v", err)
}
output := out.String()
for _, want := range []string{
"source=hunyuan-pricing-import",
"models=5",
"operator=Tencent Hunyuan",
"dry_run=true",
} {
if !strings.Contains(output, want) {
t.Fatalf("输出缺少 %q实际: %q", want, output)
}
}
}