mirror of https://github.com/docker/docker-py.git
Add build integration test checking stderr shows up in stream
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
523e6d48a7
commit
fe858f5ecc
2
Makefile
2
Makefile
|
@ -3,6 +3,8 @@
|
||||||
all: test
|
all: test
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
rm -rf tests/__pycache__
|
||||||
|
rm -rf tests/*/__pycache__
|
||||||
docker rm -vf dpy-dind
|
docker rm -vf dpy-dind
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -114,3 +114,22 @@ class BuildTest(api_test.BaseTestCase):
|
||||||
|
|
||||||
info = self.client.inspect_image('buildargs')
|
info = self.client.inspect_image('buildargs')
|
||||||
self.assertEqual(info['Config']['User'], 'OK')
|
self.assertEqual(info['Config']['User'], 'OK')
|
||||||
|
|
||||||
|
def test_build_stderr_data(self):
|
||||||
|
control_chars = ['\x1b[91m', '\x1b[0m']
|
||||||
|
snippet = 'Ancient Temple (Mystic Oriental Dream ~ Ancient Temple)'
|
||||||
|
script = io.BytesIO(b'\n'.join([
|
||||||
|
b'FROM busybox',
|
||||||
|
'RUN sh -c ">&2 echo \'{0}\'"'.format(snippet).encode('utf-8')
|
||||||
|
]))
|
||||||
|
|
||||||
|
stream = self.client.build(
|
||||||
|
fileobj=script, stream=True, decode=True, nocache=True
|
||||||
|
)
|
||||||
|
lines = []
|
||||||
|
for chunk in stream:
|
||||||
|
lines.append(chunk.get('stream'))
|
||||||
|
expected = '{0}{2}\n{1}'.format(
|
||||||
|
control_chars[0], control_chars[1], snippet
|
||||||
|
)
|
||||||
|
self.assertTrue(any([line == expected for line in lines]))
|
||||||
|
|
Loading…
Reference in New Issue