@@ -208,6 +208,48 @@ def test_import_from_stream(self):
208
208
img_id = result ['status' ]
209
209
self .tmp_imgs .append (img_id )
210
210
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
+
211
253
@contextlib .contextmanager
212
254
def temporary_http_file_server (self , stream ):
213
255
'''Serve data from an IO stream over HTTP.'''
0 commit comments