fix: артикул — распознавание DPU/BlueField профиля (BF3/BF2)
DPU-лоты (DPU_BF3_B3220-32G) не подходили под regex parsePortSpeed
(рассчитан на NIC/HCA-суффиксы NpMGbE/pFC) и падали в заглушку
категории NET с предупреждением. Добавлен parseDPUModel — структурный
разбор DPU_{FAMILY}_{MODEL} без каталога вендоров.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
37def17c5c
commit
006d7e87c5
@@ -139,6 +139,59 @@ func contains(s, sub string) bool {
|
||||
return strings.Contains(s, sub)
|
||||
}
|
||||
|
||||
func TestParsePortSpeed_DPUModel(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"DPU_BF3_B3220-32G": "BF3_B3220-32G",
|
||||
"DPU_BF2_B2220Q": "BF2_B2220Q",
|
||||
}
|
||||
for in, want := range cases {
|
||||
if got := parsePortSpeed(in); got != want {
|
||||
t.Errorf("parsePortSpeed(%q) = %q, want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestBuild_ParsesDPU verifies a DPU lot (e.g. NVIDIA BlueField) resolves to its
|
||||
// family+model token instead of falling back to the "NET" category placeholder —
|
||||
// DPU lots don't carry a NIC/HCA-style port-speed suffix, so parsePortSpeed needs
|
||||
// its own DPU branch (parseDPUModel).
|
||||
func TestBuild_ParsesDPU(t *testing.T) {
|
||||
local, err := localdb.New(filepath.Join(t.TempDir(), "local.db"))
|
||||
if err != nil {
|
||||
t.Fatalf("init local db: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { _ = local.Close() })
|
||||
|
||||
if err := local.SaveLocalPricelist(&localdb.LocalPricelist{
|
||||
ServerID: 10, Source: "estimate", Version: "v1", Name: "t",
|
||||
IsActive: true, CreatedAt: time.Now(), SyncedAt: time.Now(),
|
||||
}); err != nil {
|
||||
t.Fatalf("save pricelist: %v", err)
|
||||
}
|
||||
pl, err := local.GetLocalPricelistByServerID(10)
|
||||
if err != nil {
|
||||
t.Fatalf("get pricelist: %v", err)
|
||||
}
|
||||
if err := local.SaveLocalPricelistItems([]localdb.LocalPricelistItem{
|
||||
{PricelistID: pl.ID, LotName: "DPU_BF3_B3220-32G", LotCategory: "DPU", Price: 1},
|
||||
}); err != nil {
|
||||
t.Fatalf("save items: %v", err)
|
||||
}
|
||||
|
||||
result, err := Build(local, models.ConfigItems{
|
||||
{LotName: "DPU_BF3_B3220-32G", Quantity: 1},
|
||||
}, BuildOptions{ServerModel: "X1"})
|
||||
if err != nil {
|
||||
t.Fatalf("build: %v", err)
|
||||
}
|
||||
if len(result.Warnings) != 0 {
|
||||
t.Fatalf("expected no warnings, got %v", result.Warnings)
|
||||
}
|
||||
if !contains(result.Article, "BF3_B3220-32G") {
|
||||
t.Fatalf("expected DPU model token in article: %s", result.Article)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseGPUModel_VendorLetterSuffix(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"GPU_NV_RTX_PRO_6000D_SERVER_84GB_PCIE": "RTX6000D_84GB",
|
||||
|
||||
Reference in New Issue
Block a user