diff options
author | Joffrey F <joffrey@docker.com> | 2016-06-15 16:39:24 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2016-09-06 15:38:44 -0700 |
commit | 75497e07528a3d84a6ddd343aa66837ebb304e2a (patch) | |
tree | 1ff29bdeed946eb6ae9abf9a543c85b8c513f141 | |
parent | 65fb5be4cd30bb98f968986789bad00072b6001a (diff) | |
download | docker-py-75497e07528a3d84a6ddd343aa66837ebb304e2a.tar.gz |
Add test for import_image with changes param1064-import-changes
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | tests/integration/image_test.py | 42 |
2 files changed, 44 insertions, 3 deletions
@@ -3,9 +3,8 @@ all: test clean: - rm -rf tests/__pycache__ - rm -rf tests/*/__pycache__ - docker rm -vf dpy-dind + -docker rm -vf dpy-dind + find -name "__pycache__" | xargs rm -rf build: docker build -t docker-py . diff --git a/tests/integration/image_test.py b/tests/integration/image_test.py index 9f38366..a61b58a 100644 --- a/tests/integration/image_test.py +++ b/tests/integration/image_test.py @@ -208,6 +208,48 @@ class ImportImageTest(helpers.BaseTestCase): img_id = result['status'] 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 def temporary_http_file_server(self, stream): '''Serve data from an IO stream over HTTP.''' |