package nvidia

import (
	"testing"

	"git.mchus.pro/mchus/logpile/internal/models"
)

func TestParseInventoryComponents_IgnoresNVSwitchPropertyChecks(t *testing.T) {
	result := &models.AnalysisResult{
		Hardware: &models.HardwareConfig{},
	}

	components := []Component{
		{
			ComponentID: "NVSWITCHNVSWITCH1",
			Properties: []Property{
				{ID: "VendorID", Value: "10de"},
				{ID: "DeviceID", Value: "22a3"},
				{ID: "PCIID", Value: "0000:06:00.0"},
			},
		},
		{
			ComponentID: "NVSWITCHNum",
			Properties: []Property{
				{ID: "NVSWITCHNum", Value: 4},
			},
		},
		{
			ComponentID: "NVSWITCH_NVSWITCH1_VendorID",
			Properties: []Property{
				{ID: "NVSWITCH_NVSWITCH1_VendorID", Value: "10de"},
			},
		},
	}

	parseInventoryComponents(components, result)

	if got := len(result.Hardware.PCIeDevices); got != 1 {
		t.Fatalf("expected exactly 1 parsed NVSwitch device, got %d", got)
	}

	if result.Hardware.PCIeDevices[0].Slot != "NVSWITCH1" {
		t.Fatalf("expected slot NVSWITCH1, got %q", result.Hardware.PCIeDevices[0].Slot)
	}
}
