Merge pull request #16109 from spowelljr/fixUnitTest

tests: Fix unit test failing if docker not running
pull/16119/head
Medya Ghazizadeh 2023-03-21 11:02:14 -07:00 committed by GitHub
commit 2cd5e023e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {