mirror of https://github.com/docker/compose.git
Add --detach tests
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
1833860614
commit
c6fe564ed5
|
@ -438,7 +438,7 @@ class TopLevelCommand(object):
|
|||
use_cli = not environment.get_boolean('COMPOSE_INTERACTIVE_NO_CLI')
|
||||
index = int(options.get('--index'))
|
||||
service = self.project.get_service(options['SERVICE'])
|
||||
detach = options.get('-d') or options.get('--detach')
|
||||
detach = options.get('--detach')
|
||||
|
||||
if options['--env'] and docker.utils.version_lt(self.project.client.api_version, '1.25'):
|
||||
raise UserError("Setting environment for exec is not supported in API < 1.25'")
|
||||
|
@ -762,7 +762,7 @@ class TopLevelCommand(object):
|
|||
SERVICE [COMMAND] [ARGS...]
|
||||
|
||||
Options:
|
||||
-d --detach Detached mode: Run container in the background, print
|
||||
-d, --detach Detached mode: Run container in the background, print
|
||||
new container name.
|
||||
--name NAME Assign a name to the container
|
||||
--entrypoint CMD Override the entrypoint of the image.
|
||||
|
@ -780,7 +780,7 @@ class TopLevelCommand(object):
|
|||
-w, --workdir="" Working directory inside the container
|
||||
"""
|
||||
service = self.project.get_service(options['SERVICE'])
|
||||
detach = options.get('-d') or options.get('--detach')
|
||||
detach = options.get('--detach')
|
||||
|
||||
if options['--publish'] and options['--service-ports']:
|
||||
raise UserError(
|
||||
|
@ -963,7 +963,7 @@ class TopLevelCommand(object):
|
|||
service_names = options['SERVICE']
|
||||
timeout = timeout_from_opts(options)
|
||||
remove_orphans = options['--remove-orphans']
|
||||
detached = options.get('-d') or options.get('--detach')
|
||||
detached = options.get('--detach')
|
||||
no_start = options.get('--no-start')
|
||||
|
||||
if detached and (cascade_stop or exit_value_from):
|
||||
|
@ -1245,7 +1245,7 @@ def run_one_off_container(container_options, project, service, options, project_
|
|||
one_off=True,
|
||||
**container_options)
|
||||
|
||||
if options.get('-d') or options.get('--detach'):
|
||||
if options.get('--detach'):
|
||||
service.start_container(container)
|
||||
print(container.name)
|
||||
return
|
||||
|
@ -1372,7 +1372,7 @@ def parse_scale_args(options):
|
|||
def build_exec_command(options, container_id, command):
|
||||
args = ["exec"]
|
||||
|
||||
if options["-d"]:
|
||||
if options["--detach"]:
|
||||
args += ["--detach"]
|
||||
else:
|
||||
args += ["--interactive"]
|
||||
|
|
|
@ -884,6 +884,19 @@ class CLITestCase(DockerClientTestCase):
|
|||
assert not container.get('Config.AttachStdout')
|
||||
assert not container.get('Config.AttachStdin')
|
||||
|
||||
def test_up_detached_long_form(self):
|
||||
self.dispatch(['up', '--detach'])
|
||||
service = self.project.get_service('simple')
|
||||
another = self.project.get_service('another')
|
||||
assert len(service.containers()) == 1
|
||||
assert len(another.containers()) == 1
|
||||
|
||||
# Ensure containers don't have stdin and stdout connected in -d mode
|
||||
container, = service.containers()
|
||||
assert not container.get('Config.AttachStderr')
|
||||
assert not container.get('Config.AttachStdout')
|
||||
assert not container.get('Config.AttachStdin')
|
||||
|
||||
def test_up_attached(self):
|
||||
self.base_dir = 'tests/fixtures/echo-services'
|
||||
result = self.dispatch(['up', '--no-color'])
|
||||
|
@ -1463,6 +1476,15 @@ class CLITestCase(DockerClientTestCase):
|
|||
assert stderr == ""
|
||||
assert stdout == "/\n"
|
||||
|
||||
def test_exec_detach_long_form(self):
|
||||
self.base_dir = 'tests/fixtures/links-composefile'
|
||||
self.dispatch(['up', '--detach', 'console'])
|
||||
assert len(self.project.containers()) == 1
|
||||
|
||||
stdout, stderr = self.dispatch(['exec', '-T', 'console', 'ls', '-1d', '/'])
|
||||
assert stderr == ""
|
||||
assert stdout == "/\n"
|
||||
|
||||
def test_exec_custom_user(self):
|
||||
self.base_dir = 'tests/fixtures/links-composefile'
|
||||
self.dispatch(['up', '-d', 'console'])
|
||||
|
|
|
@ -119,7 +119,7 @@ class CLITestCase(unittest.TestCase):
|
|||
'--label': [],
|
||||
'--user': None,
|
||||
'--no-deps': None,
|
||||
'-d': False,
|
||||
'--detach': False,
|
||||
'-T': None,
|
||||
'--entrypoint': None,
|
||||
'--service-ports': None,
|
||||
|
@ -156,7 +156,7 @@ class CLITestCase(unittest.TestCase):
|
|||
'--label': [],
|
||||
'--user': None,
|
||||
'--no-deps': None,
|
||||
'-d': True,
|
||||
'--detach': True,
|
||||
'-T': None,
|
||||
'--entrypoint': None,
|
||||
'--service-ports': None,
|
||||
|
@ -177,7 +177,7 @@ class CLITestCase(unittest.TestCase):
|
|||
'--label': [],
|
||||
'--user': None,
|
||||
'--no-deps': None,
|
||||
'-d': True,
|
||||
'--detach': True,
|
||||
'-T': None,
|
||||
'--entrypoint': None,
|
||||
'--service-ports': None,
|
||||
|
@ -208,7 +208,7 @@ class CLITestCase(unittest.TestCase):
|
|||
'--label': [],
|
||||
'--user': None,
|
||||
'--no-deps': None,
|
||||
'-d': True,
|
||||
'--detach': True,
|
||||
'-T': None,
|
||||
'--entrypoint': None,
|
||||
'--service-ports': True,
|
||||
|
|
Loading…
Reference in New Issue