cleanup image expectation to reduce duplication

pull/13393/head
Steven Powell 2022-01-18 16:33:03 -08:00
parent c29c530c1b
commit daf6a28006
1 changed files with 11 additions and 4 deletions

View File

@ -272,6 +272,13 @@ func runImageList(ctx context.Context, t *testing.T, profile, testName, format s
})
}
func expectedImageFormat(format string) []string {
return []string{
fmt.Sprintf(format, "k8s.gcr.io/pause"),
fmt.Sprintf(format, "k8s.gcr.io/kube-apiserver"),
}
}
// validateImageCommands runs tests on all the `minikube image` commands, ex. `minikube image load`, `minikube image list`, etc.
func validateImageCommands(ctx context.Context, t *testing.T, profile string) {
// docs(skip): Skips on `none` driver as image loading is not supported
@ -283,10 +290,10 @@ func validateImageCommands(ctx context.Context, t *testing.T, profile string) {
t.Skip("skipping on darwin github action runners, as this test requires a running docker daemon")
}
runImageList(ctx, t, profile, "ImageListShort", "short", []string{"k8s.gcr.io/pause", "k8s.gcr.io/kube-apiserver"})
runImageList(ctx, t, profile, "ImageListTable", "table", []string{"| k8s.gcr.io/pause", "| k8s.gcr.io/kube-apiserver"})
runImageList(ctx, t, profile, "ImageListJson", "json", []string{"[\"k8s.gcr.io/pause", "[\"k8s.gcr.io/kube-apiserver"})
runImageList(ctx, t, profile, "ImageListYaml", "yaml", []string{"- k8s.gcr.io/pause", "- k8s.gcr.io/kube-apiserver"})
runImageList(ctx, t, profile, "ImageListShort", "short", expectedImageFormat("%s"))
runImageList(ctx, t, profile, "ImageListTable", "table", expectedImageFormat("| %s"))
runImageList(ctx, t, profile, "ImageListJson", "json", expectedImageFormat("[\"%s"))
runImageList(ctx, t, profile, "ImageListYaml", "yaml", expectedImageFormat("- %s"))
// docs: Make sure image building works by `minikube image build`
t.Run("ImageBuild", func(t *testing.T) {