mirror of https://github.com/docker/compose.git
Fix improper use of project.stop
Add some better test coverage for rm --stop Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
c9ff9023b2
commit
d29ed0d3e4
|
@ -680,13 +680,7 @@ class TopLevelCommand(object):
|
|||
one_off = OneOffFilter.include
|
||||
|
||||
if options.get('--stop'):
|
||||
running_containers = self.project.containers(
|
||||
service_names=options['SERVICE'], stopped=False, one_off=one_off
|
||||
)
|
||||
self.project.stop(
|
||||
service_names=running_containers,
|
||||
one_off=one_off
|
||||
)
|
||||
self.project.stop(service_names=options['SERVICE'], one_off=one_off)
|
||||
|
||||
all_containers = self.project.containers(
|
||||
service_names=options['SERVICE'], stopped=True, one_off=one_off
|
||||
|
|
|
@ -1627,8 +1627,24 @@ class CLITestCase(DockerClientTestCase):
|
|||
service = self.project.get_service('simple')
|
||||
service.create_container()
|
||||
self.dispatch(['rm', '-fs'], None)
|
||||
self.assertEqual(len(service.containers(stopped=True)), 0)
|
||||
|
||||
def test_rm_stop(self):
|
||||
self.dispatch(['up', '-d'], None)
|
||||
simple = self.project.get_service('simple')
|
||||
self.assertEqual(len(simple.containers()), 0)
|
||||
another = self.project.get_service('another')
|
||||
assert len(simple.containers()) == 1
|
||||
assert len(another.containers()) == 1
|
||||
self.dispatch(['rm', '-fs'], None)
|
||||
assert len(simple.containers(stopped=True)) == 0
|
||||
assert len(another.containers(stopped=True)) == 0
|
||||
|
||||
self.dispatch(['up', '-d'], None)
|
||||
assert len(simple.containers()) == 1
|
||||
assert len(another.containers()) == 1
|
||||
self.dispatch(['rm', '-fs', 'another'], None)
|
||||
assert len(simple.containers()) == 1
|
||||
assert len(another.containers(stopped=True)) == 0
|
||||
|
||||
def test_rm_all(self):
|
||||
service = self.project.get_service('simple')
|
||||
|
|
Loading…
Reference in New Issue