Stop accessing SetupDiGetDeviceInfoListDetail() output on error

The data returned by SetupDiGetDeviceInfoListDetail() is nil on error
which will cause the test to crash should the function fail.

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2019-02-04 11:45:37 +01:00 committed by Jason A. Donenfeld
parent e821cdabd2
commit 963be8e993

View file

@ -99,8 +99,7 @@ func TestSetupDiGetDeviceInfoListDetailLocal(t *testing.T) {
data, err := SetupDiGetDeviceInfoListDetail(devInfoList)
if err != nil {
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
}
} else {
if data.ClassGUID != deviceClassNetGUID {
t.Error("SetupDiGetDeviceInfoListDetail returned different class GUID")
}
@ -112,6 +111,7 @@ func TestSetupDiGetDeviceInfoListDetailLocal(t *testing.T) {
if data.RemoteMachineName != "" {
t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine name")
}
}
}
func TestSetupDiGetDeviceInfoListDetailRemote(t *testing.T) {
@ -124,8 +124,7 @@ func TestSetupDiGetDeviceInfoListDetailRemote(t *testing.T) {
data, err := SetupDiGetDeviceInfoListDetail(devInfoList)
if err != nil {
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
}
} else {
if data.ClassGUID != deviceClassNetGUID {
t.Error("SetupDiGetDeviceInfoListDetail returned different class GUID")
}
@ -137,6 +136,7 @@ func TestSetupDiGetDeviceInfoListDetailRemote(t *testing.T) {
if data.RemoteMachineName != computerName {
t.Error("SetupDiGetDeviceInfoListDetail returned different remote machine name")
}
}
}
func TestSetupDiEnumDeviceInfo(t *testing.T) {