From 7a38b95f8e8296ab5337ba84b22cfa25f776c266 Mon Sep 17 00:00:00 2001 From: Andriy Dzikh Date: Thu, 8 Jul 2021 13:43:49 -0700 Subject: [PATCH] Add image cleanup for local image during cache test. --- test/integration/functional_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index f7e62a41e3..898fdf0880 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -976,10 +976,22 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { t.Skipf("failed to build docker image, skipping local test: %v", err) } + defer func() { + _, err := Run(t, exec.CommandContext(ctx, "docker", "rmi", img)) + if err != nil { + t.Errorf("failed to delete local image %q, err %v", img, err) + } + }() + rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "add", img)) if err != nil { t.Errorf("failed to 'cache add' local image %q. args %q err %v", img, rr.Command(), err) } + + rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "delete", img)) + if err != nil { + t.Errorf("failed to 'cache delete' local image %q. args %q err %v", img, rr.Command(), err) + } }) t.Run("delete_k8s.gcr.io/pause:3.3", func(t *testing.T) {