Files
core/internal/ingest/parser_hardware_test.go
Mikhail Chusavitin 3dbd359d4e Canonical component types, Compare config UI
- Rename parser_hardware.go component type keys to canonical values:
  pcie -> pcie_device, psu -> power_supply
- Update normalizeComponentType to map legacy aliases (pci, psu, dimm,
  ram, processor, network_adapter, etc.) to canonical keys; treat
  "null"/"-" as unknown
- componentTypeTitle handles new canonical keys (pcie_device,
  power_supply)
- Assets list: add Compare config action — opens new window with
  slot-diff and model-count-diff tables for selected servers
- Archive Actions section spec in ui-information-architecture.md
- Add tests: normalizeComponentType aliases, componentTypeTitle aliases,
  FlattenHardwareComponents canonical type keys

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-15 14:34:22 +03:00

50 lines
1.0 KiB
Go

package ingest
import "testing"
func TestFlattenHardwareComponentsUsesCanonicalTypeKeys(t *testing.T) {
boardSerial := "BOARD-001"
input := HardwareSnapshot{
Board: HardwareBoard{SerialNumber: boardSerial},
PCIeDevices: []HardwarePCIeDevice{
{
Slot: strPtr("PCIe.Slot.1"),
Status: strPtr("OK"),
},
},
PowerSupplies: []HardwarePowerSupply{
{
Slot: strPtr("PSU1"),
SerialNumber: strPtr("PSU-SN-001"),
Status: strPtr("OK"),
},
},
}
components, _ := FlattenHardwareComponents(input)
if len(components) != 2 {
t.Fatalf("expected 2 components, got %d", len(components))
}
foundPCIe := false
foundPSU := false
for _, component := range components {
switch component.ComponentType {
case "pcie_device":
foundPCIe = true
case "power_supply":
foundPSU = true
}
}
if !foundPCIe {
t.Fatalf("expected canonical pcie_device component type")
}
if !foundPSU {
t.Fatalf("expected canonical power_supply component type")
}
}
func strPtr(value string) *string {
return &value
}