On the CI/CD, there are no pre-existing images
Also in order to have fast integration tests, we
want to maximize the effect of the cache and not
rebuild the same image twice.
@@ -25,7 +25,6 @@ import (
"time"
"4d63.com/tz"
- "github.com/docker/docker/api/types"
"github.com/sirupsen/logrus"
"github.com/GoogleContainerTools/skaffold/integration/skaffold"
@@ -104,14 +103,10 @@ func TestBuild(t *testing.T) {
}
// Run without artifact caching
- removeImage(t, test.expectImage)
skaffold.Build(append(test.args, "--cache-artifacts=false")...).InDir(test.dir).RunOrFail(t)
- checkImageExists(t, test.expectImage)
// Run with artifact caching
- removeImage(t, test.expectImage)
skaffold.Build(append(test.args, "--cache-artifacts=true")...).InDir(test.dir).RunOrFail(t)
- checkImageExists(t, test.expectImage)
// Run a second time with artifact caching
out := skaffold.Build(append(test.args, "--cache-artifacts=true")...).InDir(test.dir).RunOrFailOutput(t)
@@ -155,25 +150,6 @@ func TestExpectedBuildFailures(t *testing.T) {
}
}
-// removeImage removes the given image if present.
-func removeImage(t *testing.T, image string) {
- t.Helper()
-
- if image == "" {
- return
- }
-
- client, err := docker.NewAPIClient(&runcontext.RunContext{})
- failNowIfError(t, err)
-
- ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(5*time.Second))
- defer cancel()
- _, _ = client.ImageRemove(ctx, image, types.ImageRemoveOptions{
- Force: true,
- PruneChildren: true,
- })
-}
-
// checkImageExists asserts that the given image is present
func checkImageExists(t *testing.T, image string) {
t.Helper()
