Skip to content

Commit 75497e0

Browse files
committed
Add test for import_image with changes param
Signed-off-by: Joffrey F <[email protected]>
1 parent 65fb5be commit 75497e0

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
all: test
44

55
clean:
6-
rm -rf tests/__pycache__
7-
rm -rf tests/*/__pycache__
8-
docker rm -vf dpy-dind
6+
-docker rm -vf dpy-dind
7+
find -name "__pycache__" | xargs rm -rf
98

109
build:
1110
docker build -t docker-py .

tests/integration/image_test.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,48 @@ def test_import_from_stream(self):
208208
img_id = result['status']
209209
self.tmp_imgs.append(img_id)
210210

211+
def test_import_image_from_data_with_changes(self):
212+
with self.dummy_tar_stream(n_bytes=500) as f:
213+
content = f.read()
214+
215+
statuses = self.client.import_image_from_data(
216+
content, repository='test/import-from-bytes',
217+
changes=['USER foobar', 'CMD ["echo"]']
218+
)
219+
220+
result_text = statuses.splitlines()[-1]
221+
result = json.loads(result_text)
222+
223+
assert 'error' not in result
224+
225+
img_id = result['status']
226+
self.tmp_imgs.append(img_id)
227+
228+
img_data = self.client.inspect_image(img_id)
229+
assert img_data is not None
230+
assert img_data['Config']['Cmd'] == ['echo']
231+
assert img_data['Config']['User'] == 'foobar'
232+
233+
def test_import_image_with_changes(self):
234+
with self.dummy_tar_file(n_bytes=self.TAR_SIZE) as tar_filename:
235+
statuses = self.client.import_image(
236+
src=tar_filename, repository='test/import-from-file',
237+
changes=['USER foobar', 'CMD ["echo"]']
238+
)
239+
240+
result_text = statuses.splitlines()[-1]
241+
result = json.loads(result_text)
242+
243+
assert 'error' not in result
244+
245+
img_id = result['status']
246+
self.tmp_imgs.append(img_id)
247+
248+
img_data = self.client.inspect_image(img_id)
249+
assert img_data is not None
250+
assert img_data['Config']['Cmd'] == ['echo']
251+
assert img_data['Config']['User'] == 'foobar'
252+
211253
@contextlib.contextmanager
212254
def temporary_http_file_server(self, stream):
213255
'''Serve data from an IO stream over HTTP.'''

0 commit comments

Comments
 (0)