feat: improve inspur parsing and pci.ids integration
This commit is contained in:
40
internal/collector/redfish_pciids_test.go
Normal file
40
internal/collector/redfish_pciids_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package collector
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseNIC_ResolvesModelFromPCIIDs(t *testing.T) {
|
||||
doc := map[string]interface{}{
|
||||
"Id": "NIC1",
|
||||
"VendorId": "0x8086",
|
||||
"DeviceId": "0x1521",
|
||||
"Model": "0x1521",
|
||||
}
|
||||
|
||||
nic := parseNIC(doc)
|
||||
if nic.Model == "" {
|
||||
t.Fatalf("expected model resolved from pci.ids")
|
||||
}
|
||||
if !strings.Contains(strings.ToUpper(nic.Model), "I350") {
|
||||
t.Fatalf("expected I350 in model, got %q", nic.Model)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsePCIeFunction_ResolvesDeviceClassFromPCIIDs(t *testing.T) {
|
||||
doc := map[string]interface{}{
|
||||
"Id": "PCIE1",
|
||||
"VendorId": "0x9005",
|
||||
"DeviceId": "0x028f",
|
||||
"ClassCode": "0x010700",
|
||||
}
|
||||
|
||||
dev := parsePCIeFunction(doc, 0)
|
||||
if dev.DeviceClass == "" || strings.EqualFold(dev.DeviceClass, "PCIe device") {
|
||||
t.Fatalf("expected device class resolved from pci.ids, got %q", dev.DeviceClass)
|
||||
}
|
||||
if strings.HasPrefix(strings.ToLower(strings.TrimSpace(dev.DeviceClass)), "0x") {
|
||||
t.Fatalf("expected resolved name instead of raw hex, got %q", dev.DeviceClass)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user