Kaydet (Commit) 75497e07 authored tarafından Joffrey F's avatar Joffrey F

Add test for import_image with changes param

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 65fb5be4
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
all: test all: test
clean: clean:
rm -rf tests/__pycache__ -docker rm -vf dpy-dind
rm -rf tests/*/__pycache__ find -name "__pycache__" | xargs rm -rf
docker rm -vf dpy-dind
build: build:
docker build -t docker-py . docker build -t docker-py .
......
...@@ -208,6 +208,48 @@ class ImportImageTest(helpers.BaseTestCase): ...@@ -208,6 +208,48 @@ class ImportImageTest(helpers.BaseTestCase):
img_id = result['status'] img_id = result['status']
self.tmp_imgs.append(img_id) self.tmp_imgs.append(img_id)
def test_import_image_from_data_with_changes(self):
with self.dummy_tar_stream(n_bytes=500) as f:
content = f.read()
statuses = self.client.import_image_from_data(
content, repository='test/import-from-bytes',
changes=['USER foobar', 'CMD ["echo"]']
)
result_text = statuses.splitlines()[-1]
result = json.loads(result_text)
assert 'error' not in result
img_id = result['status']
self.tmp_imgs.append(img_id)
img_data = self.client.inspect_image(img_id)
assert img_data is not None
assert img_data['Config']['Cmd'] == ['echo']
assert img_data['Config']['User'] == 'foobar'
def test_import_image_with_changes(self):
with self.dummy_tar_file(n_bytes=self.TAR_SIZE) as tar_filename:
statuses = self.client.import_image(
src=tar_filename, repository='test/import-from-file',
changes=['USER foobar', 'CMD ["echo"]']
)
result_text = statuses.splitlines()[-1]
result = json.loads(result_text)
assert 'error' not in result
img_id = result['status']
self.tmp_imgs.append(img_id)
img_data = self.client.inspect_image(img_id)
assert img_data is not None
assert img_data['Config']['Cmd'] == ['echo']
assert img_data['Config']['User'] == 'foobar'
@contextlib.contextmanager @contextlib.contextmanager
def temporary_http_file_server(self, stream): def temporary_http_file_server(self, stream):
'''Serve data from an IO stream over HTTP.''' '''Serve data from an IO stream over HTTP.'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment