@@ -145,3 +145,54 @@ func TestStartStopWithDependencies(t *testing.T) {
145
145
_ = c .RunDockerComposeCmd (t , "--project-name" , projectName , "down" )
146
146
})
147
147
}
148
+
149
+ func TestStartStopWithOneOffs (t * testing.T ) {
150
+ c := NewParallelCLI (t )
151
+ const projectName = "e2e-start-stop-with-oneoffs"
152
+
153
+ t .Run ("Up" , func (t * testing.T ) {
154
+ res := c .RunDockerComposeCmd (t , "-f" , "./fixtures/dependencies/compose.yaml" , "--project-name" , projectName ,
155
+ "up" , "-d" )
156
+ assert .Assert (t , strings .Contains (res .Combined (), "Container e2e-start-stop-with-oneoffs-foo-1 Started" ), res .Combined ())
157
+ assert .Assert (t , strings .Contains (res .Combined (), "Container e2e-start-stop-with-oneoffs-bar-1 Started" ), res .Combined ())
158
+ })
159
+
160
+ t .Run ("run one-off" , func (t * testing.T ) {
161
+ c .RunDockerComposeCmd (t , "-f" , "./fixtures/dependencies/compose.yaml" , "--project-name" , projectName , "run" , "-d" , "bar" , "sleep" , "infinity" )
162
+ res := c .RunDockerComposeCmd (t , "--project-name" , projectName , "ps" , "-a" )
163
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs-foo-1" ), res .Combined ())
164
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs-bar-1" ), res .Combined ())
165
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs_bar_run" ), res .Combined ())
166
+ })
167
+
168
+ t .Run ("stop (not one-off containers)" , func (t * testing.T ) {
169
+ res := c .RunDockerComposeCmd (t , "--project-name" , projectName , "stop" )
170
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs-foo-1" ), res .Combined ())
171
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs-bar-1" ), res .Combined ())
172
+ assert .Assert (t , ! strings .Contains (res .Combined (), "e2e_start_stop_with_oneoffs_bar_run" ), res .Combined ())
173
+
174
+ res = c .RunDockerComposeCmd (t , "--project-name" , projectName , "ps" , "-a" , "--status" , "running" )
175
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs_bar_run" ), res .Combined ())
176
+ })
177
+
178
+ t .Run ("start (not one-off containers)" , func (t * testing.T ) {
179
+ res := c .RunDockerComposeCmd (t , "--project-name" , projectName , "start" )
180
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs-foo-1" ), res .Combined ())
181
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs-bar-1" ), res .Combined ())
182
+ assert .Assert (t , ! strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs_bar_run" ), res .Combined ())
183
+ })
184
+
185
+ t .Run ("restart (not one-off containers)" , func (t * testing.T ) {
186
+ res := c .RunDockerComposeCmd (t , "--project-name" , projectName , "restart" )
187
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs-foo-1" ), res .Combined ())
188
+ assert .Assert (t , strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs-bar-1" ), res .Combined ())
189
+ assert .Assert (t , ! strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs_bar_run" ), res .Combined ())
190
+ })
191
+
192
+ t .Run ("down" , func (t * testing.T ) {
193
+ c .RunDockerComposeCmd (t , "--project-name" , projectName , "down" , "--remove-orphans" )
194
+
195
+ res := c .RunDockerComposeCmd (t , "--project-name" , projectName , "ps" , "-a" , "--status" , "running" )
196
+ assert .Assert (t , ! strings .Contains (res .Combined (), "e2e-start-stop-with-oneoffs-bar" ), res .Combined ())
197
+ })
198
+ }
0 commit comments