Skip to content

Commit

Permalink
Merge pull request #16109 from spowelljr/fixUnitTest
Browse files Browse the repository at this point in the history
tests: Fix unit test failing if docker not running
  • Loading branch information
medyagh authored Mar 21, 2023
2 parents 856e706 + 35b0b56 commit 2cd5e02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/drivers/kic/oci/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/minikube/registry/drvs/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2cd5e02

Please sign in to comment.