Kaydet (Commit) ced9b009 authored tarafından Aanand Prasad's avatar Aanand Prasad

Fix .dockerignore integration test

- There was a typo (".dockerginore"), which meant that the exclusion of
  the .dockerignore file itself wasn't being tested.

- Some of the file names were non-descriptive.

- The test was inspecting the output of the build process, rather than
  running 'ls' in a new container, which meant it was full of extra
  output, and would fail when there was a cache hit.
Signed-off-by: 's avatarAanand Prasad <aanand.prasad@gmail.com>
üst d60cb317
...@@ -1303,35 +1303,41 @@ class TestBuildWithDockerignore(Cleanup, BaseTestCase): ...@@ -1303,35 +1303,41 @@ class TestBuildWithDockerignore(Cleanup, BaseTestCase):
'FROM busybox', 'FROM busybox',
'MAINTAINER docker-py', 'MAINTAINER docker-py',
'ADD . /test', 'ADD . /test',
'RUN ls -A /test',
])) ]))
with open(os.path.join(base_dir, '.dockerignore'), 'w') as f: with open(os.path.join(base_dir, '.dockerignore'), 'w') as f:
f.write("\n".join([ f.write("\n".join([
'node_modules', 'ignored',
'Dockerfile', 'Dockerfile',
'.dockerginore', '.dockerignore',
'', # empty line '', # empty line
])) ]))
with open(os.path.join(base_dir, 'not-ignored'), 'w') as f: with open(os.path.join(base_dir, 'not-ignored'), 'w') as f:
f.write("this file should not be ignored") f.write("this file should not be ignored")
subdir = os.path.join(base_dir, 'node_modules', 'grunt-cli') subdir = os.path.join(base_dir, 'ignored', 'subdir')
os.makedirs(subdir) os.makedirs(subdir)
with open(os.path.join(subdir, 'grunt'), 'w') as f: with open(os.path.join(subdir, 'file'), 'w') as f:
f.write("grunt") f.write("this file should be ignored")
stream = self.client.build(path=base_dir, stream=True) tag = 'docker-py-test-build-with-dockerignore'
logs = '' stream = self.client.build(
path=base_dir,
tag=tag,
)
for chunk in stream: for chunk in stream:
if six.PY3: pass
chunk = chunk.decode('utf-8')
logs += chunk c = self.client.create_container(tag, ['ls', '-1A', '/test'])
self.assertFalse('node_modules' in logs) self.client.start(c)
self.assertFalse('Dockerfile' in logs) self.client.wait(c)
self.assertFalse('.dockerginore' in logs) logs = self.client.logs(c)
self.assertTrue('not-ignored' in logs)
self.assertEqual(
filter(None, logs.split('\n')),
['not-ignored'],
)
####################### #######################
# PY SPECIFIC TESTS # # PY SPECIFIC TESTS #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment