summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-02-04 11:45:37 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-05 12:59:42 +0100
commit963be8e993ae5688f3b0c490813a95391ec98c53 (patch)
treef66b410db599c8eb803c5046aed56fdfe1e47bba
parente821cdabd2930d301d3a12a5d4d1fe8904cd1c14 (diff)
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>
-rw-r--r--setupapi/setupapi_windows_test.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/setupapi/setupapi_windows_test.go b/setupapi/setupapi_windows_test.go
index 062b6bd..17d6d8e 100644
--- a/setupapi/setupapi_windows_test.go
+++ b/setupapi/setupapi_windows_test.go
@@ -99,18 +99,18 @@ func TestSetupDiGetDeviceInfoListDetailLocal(t *testing.T) {
data, err := SetupDiGetDeviceInfoListDetail(devInfoList)
if err != nil {
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
- }
-
- if data.ClassGUID != deviceClassNetGUID {
- t.Error("SetupDiGetDeviceInfoListDetail returned different class GUID")
- }
+ } else {
+ if data.ClassGUID != deviceClassNetGUID {
+ t.Error("SetupDiGetDeviceInfoListDetail returned different class GUID")
+ }
- if data.RemoteMachineHandle != windows.Handle(0) {
- t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine handle")
- }
+ if data.RemoteMachineHandle != windows.Handle(0) {
+ t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine handle")
+ }
- if data.RemoteMachineName != "" {
- t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine name")
+ if data.RemoteMachineName != "" {
+ t.Error("SetupDiGetDeviceInfoListDetail returned non-NULL remote machine name")
+ }
}
}
@@ -124,18 +124,18 @@ func TestSetupDiGetDeviceInfoListDetailRemote(t *testing.T) {
data, err := SetupDiGetDeviceInfoListDetail(devInfoList)
if err != nil {
t.Errorf("Error calling SetupDiGetDeviceInfoListDetail: %s", err.Error())
- }
-
- if data.ClassGUID != deviceClassNetGUID {
- t.Error("SetupDiGetDeviceInfoListDetail returned different class GUID")
- }
+ } else {
+ if data.ClassGUID != deviceClassNetGUID {
+ t.Error("SetupDiGetDeviceInfoListDetail returned different class GUID")
+ }
- if data.RemoteMachineHandle == windows.Handle(0) {
- t.Error("SetupDiGetDeviceInfoListDetail returned NULL remote machine handle")
- }
+ if data.RemoteMachineHandle == windows.Handle(0) {
+ t.Error("SetupDiGetDeviceInfoListDetail returned NULL remote machine handle")
+ }
- if data.RemoteMachineName != computerName {
- t.Error("SetupDiGetDeviceInfoListDetail returned different remote machine name")
+ if data.RemoteMachineName != computerName {
+ t.Error("SetupDiGetDeviceInfoListDetail returned different remote machine name")
+ }
}
}