mirror of https://github.com/docker/compose.git
make compose pull tests more expressive
Signed-off-by: Vedant Koditkar <vedant.koditkar@outlook.com>
This commit is contained in:
parent
e623b5ca1e
commit
0db6dfee03
|
@ -122,31 +122,49 @@ func TestLocalComposeUp(t *testing.T) {
|
||||||
func TestComposePull(t *testing.T) {
|
func TestComposePull(t *testing.T) {
|
||||||
c := NewParallelCLI(t)
|
c := NewParallelCLI(t)
|
||||||
|
|
||||||
res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/simple-composefile", "pull")
|
t.Run("Verify image pulled", func(t *testing.T) {
|
||||||
output := res.Combined()
|
// cleanup existing images
|
||||||
|
c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/simple", "down", "--rmi", "all")
|
||||||
|
|
||||||
expected := []string{
|
res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/simple", "pull")
|
||||||
"Skipped - No image to be pulled",
|
output := res.Combined()
|
||||||
"Skipped - Image is already present locally",
|
|
||||||
"Skipped - Image is already being pulled by",
|
|
||||||
"simple Pulled",
|
|
||||||
"another Pulled",
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.Assert(t, contains(output, expected))
|
assert.Assert(t, strings.Contains(output, "simple Pulled"))
|
||||||
}
|
assert.Assert(t, strings.Contains(output, "another Pulled"))
|
||||||
|
})
|
||||||
|
|
||||||
func contains(str string, array []string) bool {
|
t.Run("Verify a image is pulled once", func(t *testing.T) {
|
||||||
found := false
|
// cleanup existing images
|
||||||
|
c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/duplicate-images", "down", "--rmi", "all")
|
||||||
|
|
||||||
for _, val := range array {
|
res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/duplicate-images", "pull")
|
||||||
if strings.Contains(str, val) {
|
output := res.Combined()
|
||||||
found = true
|
|
||||||
break
|
if strings.Contains(output, "another Pulled") {
|
||||||
|
assert.Assert(t, strings.Contains(output, "another Pulled"))
|
||||||
|
assert.Assert(t, strings.Contains(output, "Skipped - Image is already being pulled by another"))
|
||||||
|
} else {
|
||||||
|
assert.Assert(t, strings.Contains(output, "simple Pulled"))
|
||||||
|
assert.Assert(t, strings.Contains(output, "Skipped - Image is already being pulled by simple"))
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
return found
|
t.Run("Verify skipped pull if image is already present locally", func(t *testing.T) {
|
||||||
|
// make sure the requied image is present
|
||||||
|
c.RunDockerCmd(t, "pull", "alpine")
|
||||||
|
|
||||||
|
res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/image-present-locally", "pull")
|
||||||
|
output := res.Combined()
|
||||||
|
|
||||||
|
assert.Assert(t, strings.Contains(output, "Skipped - Image is already present locally"))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("Verify skipped no image to be pulled", func(t *testing.T) {
|
||||||
|
res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/no-image-name-given", "pull")
|
||||||
|
output := res.Combined()
|
||||||
|
|
||||||
|
assert.Assert(t, strings.Contains(output, "Skipped - No image to be pulled"))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDownComposefileInParentFolder(t *testing.T) {
|
func TestDownComposefileInParentFolder(t *testing.T) {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
services:
|
||||||
|
simple:
|
||||||
|
image: alpine:3.13
|
||||||
|
command: top
|
||||||
|
another:
|
||||||
|
image: alpine:3.13
|
||||||
|
command: top
|
|
@ -0,0 +1,4 @@
|
||||||
|
services:
|
||||||
|
simple:
|
||||||
|
image: alpine
|
||||||
|
command: top
|
|
@ -0,0 +1,3 @@
|
||||||
|
services:
|
||||||
|
no-image-service:
|
||||||
|
build: .
|
|
@ -0,0 +1,7 @@
|
||||||
|
services:
|
||||||
|
simple:
|
||||||
|
image: alpine:3.14
|
||||||
|
command: top
|
||||||
|
another:
|
||||||
|
image: alpine:3.15
|
||||||
|
command: top
|
Loading…
Reference in New Issue