From 04a3af2ad26dd37db7f107f0225547ccbee0c1c8 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Wed, 27 Sep 2023 13:55:20 -0700 Subject: [PATCH] fix possible nil reference in test --- cmd/minikube/cmd/start_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/minikube/cmd/start_test.go b/cmd/minikube/cmd/start_test.go index d5ad31ec7033..a3e2f7a1603d 100644 --- a/cmd/minikube/cmd/start_test.go +++ b/cmd/minikube/cmd/start_test.go @@ -870,13 +870,17 @@ func TestValidateEnableNvidiaGPUs(t *testing.T) { {false, "kvm", "containerd", ""}, {true, "docker", "docker", ""}, {true, "docker", "", ""}, - {true, "kvm", "docker", "The nvidia-docker container-runtime can only be run with the docker driver"}, - {true, "docker", "containerd", "The nvidia-docker container-runtime can only be run with the docker driver"}, + {true, "kvm", "docker", "The enable-nvidia-gpus flag can only be run with the docker driver and docker container-runtime"}, + {true, "docker", "containerd", "The enable-nvidia-gpus flag can only be run with the docker driver and docker container-runtime"}, } for _, tc := range tests { + gotError := "" got := validateEnableNvidiaGPUs(tc.enableNvidiaGPUs, tc.drvName, tc.runtime) - if got.Error() != tc.errorMsg { + if got != nil { + gotError = got.Error() + } + if gotError != tc.errorMsg { t.Errorf("validateEnableNvidiaGPUs(%t, %s, %s) = %q; want = %q", tc.enableNvidiaGPUs, tc.drvName, tc.runtime, got, tc.errorMsg) } }