Skip to content

Commit

Permalink
added unit test for validate func
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr committed Sep 27, 2023
1 parent 89b93d0 commit 5e250c4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/minikube/cmd/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,3 +859,25 @@ func TestImageMatchesBinaryVersion(t *testing.T) {
}
}
}

func TestValidateEnableNvidiaGPUs(t *testing.T) {
tests := []struct {
enableNvidiaGPUs bool
drvName string
runtime string
errorMsg string
}{
{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"},
}

for _, tc := range tests {
got := validateEnableNvidiaGPUs(tc.enableNvidiaGPUs, tc.drvName, tc.runtime)
if got.Error() != tc.errorMsg {
t.Errorf("validateEnableNvidiaGPUs(%t, %s, %s) = %q; want = %q", tc.enableNvidiaGPUs, tc.drvName, tc.runtime, got, tc.errorMsg)
}
}
}

0 comments on commit 5e250c4

Please sign in to comment.