53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package inspur
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.mchus.pro/mchus/logpile/internal/models"
|
|
)
|
|
|
|
func TestParseNetworkAdapterInfo_ResolvesModelFromPCIIDsForRawHexModel(t *testing.T) {
|
|
text := `RESTful Network Adapter info:
|
|
{
|
|
"sys_adapters": [
|
|
{
|
|
"id": 1,
|
|
"name": "NIC1",
|
|
"Location": "#CPU0_PCIE4",
|
|
"present": 1,
|
|
"slot": 4,
|
|
"vendor_id": 32902,
|
|
"device_id": 5409,
|
|
"vendor": "",
|
|
"model": "0x1521",
|
|
"fw_ver": "",
|
|
"status": "OK",
|
|
"sn": "",
|
|
"pn": "",
|
|
"port_num": 4,
|
|
"port_type": "Base-T",
|
|
"ports": []
|
|
}
|
|
]
|
|
}
|
|
RESTful fan`
|
|
|
|
hw := &models.HardwareConfig{}
|
|
parseNetworkAdapterInfo(text, hw)
|
|
|
|
if len(hw.NetworkAdapters) != 1 {
|
|
t.Fatalf("expected 1 network adapter, got %d", len(hw.NetworkAdapters))
|
|
}
|
|
got := hw.NetworkAdapters[0]
|
|
if got.Model == "" {
|
|
t.Fatalf("expected NIC model resolved from pci.ids, got empty")
|
|
}
|
|
if !strings.Contains(strings.ToUpper(got.Model), "I350") {
|
|
t.Fatalf("expected I350 in model, got %q", got.Model)
|
|
}
|
|
if got.Vendor == "" {
|
|
t.Fatalf("expected NIC vendor resolved from pci.ids")
|
|
}
|
|
}
|