summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2017-02-15 18:42:49 -0800
committerJoffrey F <joffrey@docker.com>2017-02-15 19:13:24 -0800
commit0a97df1abc7236793b82041626088f54ad8d204f (patch)
treea7a641324672d81380009edad35883afdd6a77f0 /tests
parent4a50784ad432283a1bd314da0c574fbe5699f1c9 (diff)
downloaddocker-py-0a97df1abc7236793b82041626088f54ad8d204f.tar.gz
Rename cachefrom -> cache_from
Fix cache_from integration test Fix image ID detection in ImageCollection.build Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_build_test.py44
1 files changed, 29 insertions, 15 deletions
diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py
index c2fd26c..fe5d994 100644
--- a/tests/integration/api_build_test.py
+++ b/tests/integration/api_build_test.py
@@ -3,13 +3,12 @@ import os
import shutil
import tempfile
-import pytest
-import six
-
from docker import errors
-from ..helpers import requires_api_version
+import six
+
from .base import BaseAPIIntegrationTest
+from ..helpers import requires_api_version
class BuildTest(BaseAPIIntegrationTest):
@@ -155,25 +154,40 @@ class BuildTest(BaseAPIIntegrationTest):
self.assertEqual(info['Config']['Labels'], labels)
@requires_api_version('1.25')
- @pytest.mark.xfail(reason='Bad test')
- def test_build_cachefrom(self):
+ def test_build_with_cache_from(self):
script = io.BytesIO('\n'.join([
- 'FROM scratch',
- 'CMD sh -c "echo \'Hello, World!\'"',
+ 'FROM busybox',
+ 'ENV FOO=bar',
+ 'RUN touch baz',
+ 'RUN touch bax',
]).encode('ascii'))
- cachefrom = ['build1']
+ stream = self.client.build(fileobj=script, tag='build1')
+ self.tmp_imgs.append('build1')
+ for chunk in stream:
+ pass
stream = self.client.build(
- fileobj=script, tag='cachefrom', cachefrom=cachefrom
+ fileobj=script, tag='build2', cache_from=['build1'],
+ decode=True
)
- self.tmp_imgs.append('cachefrom')
+ self.tmp_imgs.append('build2')
+ counter = 0
for chunk in stream:
- pass
+ if 'Using cache' in chunk.get('stream', ''):
+ counter += 1
+ assert counter == 3
+ self.client.remove_image('build2')
- info = self.client.inspect_image('cachefrom')
- # FIXME: Config.CacheFrom is not a real thing
- self.assertEqual(info['Config']['CacheFrom'], cachefrom)
+ counter = 0
+ stream = self.client.build(
+ fileobj=script, tag='build2', cache_from=['nosuchtag'],
+ decode=True
+ )
+ for chunk in stream:
+ if 'Using cache' in chunk.get('stream', ''):
+ counter += 1
+ assert counter == 0
def test_build_stderr_data(self):
control_chars = ['\x1b[91m', '\x1b[0m']