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 }