tests: fix unit test failing if docker not running

pull/16109/head
Steven Powell 2023-03-20 16:59:47 -07:00
parent 9d1c4ebf4e
commit 35b0b56e9e
2 changed files with 3 additions and 1 deletions

View File

@ -44,7 +44,7 @@ var (
)
// CachedDaemonInfo will run and return a docker/podman info only once per minikube run time. to avoid performance
func CachedDaemonInfo(ociBin string) (SysInfo, error) {
var CachedDaemonInfo = func(ociBin string) (SysInfo, error) {
if cachedSysInfo == nil {
si, err := DaemonInfo(ociBin)
cachedSysInfo = &si

View File

@ -22,6 +22,7 @@ import (
"testing"
"github.com/blang/semver/v4"
"k8s.io/minikube/pkg/drivers/kic/oci"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/registry"
)
@ -185,6 +186,7 @@ func TestStatus(t *testing.T) {
}
for _, tt := range tests {
dockerVersionOrState = func() (string, registry.State) { return tt.input, registry.State{} }
oci.CachedDaemonInfo = func(string) (oci.SysInfo, error) { return oci.SysInfo{}, nil }
state := status()
err := state.Error
if (err == nil && tt.shouldReturnError) || (err != nil && !tt.shouldReturnError) {