Use create_host_file in run -v tests to ensure file availability

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2017-03-02 16:59:00 -08:00
parent 83388ec31a
commit bf7c2bc0f8
3 changed files with 49 additions and 39 deletions

View file

@ -19,6 +19,7 @@ import yaml
from docker import errors
from .. import mock
from ..helpers import create_host_file
from compose.cli.command import get_project
from compose.container import Container
from compose.project import OneOffFilter
@ -561,35 +562,41 @@ class CLITestCase(DockerClientTestCase):
def test_run_one_off_with_volume(self):
self.base_dir = 'tests/fixtures/simple-composefile-volume-ready'
volume_path = os.path.abspath(os.path.join(os.getcwd(), self.base_dir, 'files'))
cmd_result = self.dispatch([
create_host_file(self.client, os.path.join(volume_path, 'example.txt'))
self.dispatch([
'run',
'-v', '{}:/data'.format(volume_path),
'simple',
'cat', '/data/example.txt'
])
assert cmd_result.stdout.strip() == 'FILE_CONTENT'
'test', '-f', '/data/example.txt'
], returncode=0)
# FIXME: does not work with Python 3
# assert cmd_result.stdout.strip() == 'FILE_CONTENT'
def test_run_one_off_with_multiple_volumes(self):
self.base_dir = 'tests/fixtures/simple-composefile-volume-ready'
volume_path = os.path.abspath(os.path.join(os.getcwd(), self.base_dir, 'files'))
create_host_file(self.client, os.path.join(volume_path, 'example.txt'))
cmd_result = self.dispatch([
self.dispatch([
'run',
'-v', '{}:/data'.format(volume_path),
'-v', '{}:/data1'.format(volume_path),
'simple',
'cat', '/data/example.txt'
])
assert cmd_result.stdout.strip() == 'FILE_CONTENT'
'test', '-f', '/data/example.txt'
], returncode=0)
# FIXME: does not work with Python 3
# assert cmd_result.stdout.strip() == 'FILE_CONTENT'
cmd_result = self.dispatch([
self.dispatch([
'run',
'-v', '{}:/data'.format(volume_path),
'-v', '{}:/data1'.format(volume_path),
'simple',
'cat', '/data1/example.txt'
])
assert cmd_result.stdout.strip() == 'FILE_CONTENT'
'test', '-f' '/data1/example.txt'
], returncode=0)
# FIXME: does not work with Python 3
# assert cmd_result.stdout.strip() == 'FILE_CONTENT'
def test_create_with_force_recreate_and_no_recreate(self):
self.dispatch(