@@ -122,31 +122,49 @@ func TestLocalComposeUp(t *testing.T) {
122122func TestComposePull (t * testing.T ) {
123123 c := NewParallelCLI (t )
124124
125- res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/simple-composefile" , "pull" )
126- output := res .Combined ()
127-
128- expected := []string {
129- "Skipped - No image to be pulled" ,
130- "Skipped - Image is already present locally" ,
131- "Skipped - Image is already being pulled by" ,
132- "simple Pulled" ,
133- "another Pulled" ,
134- }
135-
136- assert .Assert (t , contains (output , expected ))
137- }
125+ t .Run ("Verify image pulled" , func (t * testing.T ) {
126+ // cleanup existing images
127+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/compose-pull/simple" , "down" , "--rmi" , "all" )
128+
129+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/compose-pull/simple" , "pull" )
130+ output := res .Combined ()
131+
132+ assert .Assert (t , strings .Contains (output , "simple Pulled" ))
133+ assert .Assert (t , strings .Contains (output , "another Pulled" ))
134+ })
135+
136+ t .Run ("Verify a image is pulled once" , func (t * testing.T ) {
137+ // cleanup existing images
138+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/compose-pull/duplicate-images" , "down" , "--rmi" , "all" )
138139
139- func contains ( str string , array [] string ) bool {
140- found := false
140+ res := c . RunDockerComposeCmd ( t , "--project-directory" , "fixtures/compose-pull/duplicate-images" , "pull" )
141+ output := res . Combined ()
141142
142- for _ , val := range array {
143- if strings .Contains (str , val ) {
144- found = true
145- break
143+ if strings .Contains (output , "another Pulled" ) {
144+ assert .Assert (t , strings .Contains (output , "another Pulled" ))
145+ assert .Assert (t , strings .Contains (output , "Skipped - Image is already being pulled by another" ))
146+ } else {
147+ assert .Assert (t , strings .Contains (output , "simple Pulled" ))
148+ assert .Assert (t , strings .Contains (output , "Skipped - Image is already being pulled by simple" ))
146149 }
147- }
150+ })
148151
149- return found
152+ t .Run ("Verify skipped pull if image is already present locally" , func (t * testing.T ) {
153+ // make sure the requied image is present
154+ c .RunDockerCmd (t , "pull" , "alpine" )
155+
156+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/compose-pull/image-present-locally" , "pull" )
157+ output := res .Combined ()
158+
159+ assert .Assert (t , strings .Contains (output , "Skipped - Image is already present locally" ))
160+ })
161+
162+ t .Run ("Verify skipped no image to be pulled" , func (t * testing.T ) {
163+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/compose-pull/no-image-name-given" , "pull" )
164+ output := res .Combined ()
165+
166+ assert .Assert (t , strings .Contains (output , "Skipped - No image to be pulled" ))
167+ })
150168}
151169
152170func TestDownComposefileInParentFolder (t * testing.T ) {
0 commit comments