(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func TestComposePull(t *testing.T) { |
| 28 | c := NewParallelCLI(t) |
| 29 | |
| 30 | t.Run("Verify image pulled", func(t *testing.T) { |
| 31 | // cleanup existing images |
| 32 | c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/simple", "down", "--rmi", "all") |
| 33 | |
| 34 | res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/simple", "pull") |
| 35 | output := res.Combined() |
| 36 | |
| 37 | assert.Assert(t, strings.Contains(output, "Image alpine:3.14 Pulled")) |
| 38 | assert.Assert(t, strings.Contains(output, "Image alpine:3.15 Pulled")) |
| 39 | |
| 40 | // verify default policy is 'always' for pull command |
| 41 | res = c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/simple", "pull") |
| 42 | output = res.Combined() |
| 43 | |
| 44 | assert.Assert(t, strings.Contains(output, "Image alpine:3.14 Pulled")) |
| 45 | assert.Assert(t, strings.Contains(output, "Image alpine:3.15 Pulled")) |
| 46 | }) |
| 47 | |
| 48 | t.Run("Verify skipped pull if image is already present locally", func(t *testing.T) { |
| 49 | // make sure the required image is present |
| 50 | c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/image-present-locally", "pull") |
| 51 | |
| 52 | res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/image-present-locally", "pull") |
| 53 | output := res.Combined() |
| 54 | |
| 55 | assert.Assert(t, strings.Contains(output, "alpine:3.13.12 Skipped Image is already present locally")) |
| 56 | // image with :latest tag gets pulled regardless if pull_policy: missing or if_not_present |
| 57 | assert.Assert(t, strings.Contains(output, "alpine:latest Pulled")) |
| 58 | }) |
| 59 | |
| 60 | t.Run("Verify skipped no image to be pulled", func(t *testing.T) { |
| 61 | res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/no-image-name-given", "pull") |
| 62 | output := res.Combined() |
| 63 | |
| 64 | assert.Assert(t, strings.Contains(output, "Skipped No image to be pulled")) |
| 65 | }) |
| 66 | |
| 67 | t.Run("Verify pull failure", func(t *testing.T) { |
| 68 | res := c.RunDockerComposeCmdNoCheck(t, "--project-directory", "fixtures/compose-pull/unknown-image", "pull") |
| 69 | res.Assert(t, icmd.Expected{ExitCode: 1, Err: "pull access denied for does_not_exists"}) |
| 70 | }) |
| 71 | |
| 72 | t.Run("Verify ignore pull failure", func(t *testing.T) { |
| 73 | res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/unknown-image", "pull", "--ignore-pull-failures") |
| 74 | res.Assert(t, icmd.Expected{Err: "Some service image(s) must be built from source by running:"}) |
| 75 | }) |
| 76 | } |
nothing calls this directly
no test coverage detected