Skip to content

Commit ced9b00

Browse files
committed
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: Aanand Prasad <[email protected]>
1 parent d60cb31 commit ced9b00

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

tests/integration_test.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,35 +1303,41 @@ def runTest(self):
13031303
'FROM busybox',
13041304
'MAINTAINER docker-py',
13051305
'ADD . /test',
1306-
'RUN ls -A /test',
13071306
]))
13081307

13091308
with open(os.path.join(base_dir, '.dockerignore'), 'w') as f:
13101309
f.write("\n".join([
1311-
'node_modules',
1310+
'ignored',
13121311
'Dockerfile',
1313-
'.dockerginore',
1312+
'.dockerignore',
13141313
'', # empty line
13151314
]))
13161315

13171316
with open(os.path.join(base_dir, 'not-ignored'), 'w') as f:
13181317
f.write("this file should not be ignored")
13191318

1320-
subdir = os.path.join(base_dir, 'node_modules', 'grunt-cli')
1319+
subdir = os.path.join(base_dir, 'ignored', 'subdir')
13211320
os.makedirs(subdir)
1322-
with open(os.path.join(subdir, 'grunt'), 'w') as f:
1323-
f.write("grunt")
1321+
with open(os.path.join(subdir, 'file'), 'w') as f:
1322+
f.write("this file should be ignored")
13241323

1325-
stream = self.client.build(path=base_dir, stream=True)
1326-
logs = ''
1324+
tag = 'docker-py-test-build-with-dockerignore'
1325+
stream = self.client.build(
1326+
path=base_dir,
1327+
tag=tag,
1328+
)
13271329
for chunk in stream:
1328-
if six.PY3:
1329-
chunk = chunk.decode('utf-8')
1330-
logs += chunk
1331-
self.assertFalse('node_modules' in logs)
1332-
self.assertFalse('Dockerfile' in logs)
1333-
self.assertFalse('.dockerginore' in logs)
1334-
self.assertTrue('not-ignored' in logs)
1330+
pass
1331+
1332+
c = self.client.create_container(tag, ['ls', '-1A', '/test'])
1333+
self.client.start(c)
1334+
self.client.wait(c)
1335+
logs = self.client.logs(c)
1336+
1337+
self.assertEqual(
1338+
filter(None, logs.split('\n')),
1339+
['not-ignored'],
1340+
)
13351341

13361342
#######################
13371343
# PY SPECIFIC TESTS #

0 commit comments

Comments
 (0)