Skip to content

Commit 9b37120

Browse files
committed
Merge pull request #742 from aanand/fix-dockerignore-integration-test
Fix .dockerignore integration test
2 parents 63df0b9 + ced9b00 commit 9b37120

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
@@ -1388,35 +1388,41 @@ def runTest(self):
13881388
'FROM busybox',
13891389
'MAINTAINER docker-py',
13901390
'ADD . /test',
1391-
'RUN ls -A /test',
13921391
]))
13931392

13941393
with open(os.path.join(base_dir, '.dockerignore'), 'w') as f:
13951394
f.write("\n".join([
1396-
'node_modules',
1395+
'ignored',
13971396
'Dockerfile',
1398-
'.dockerginore',
1397+
'.dockerignore',
13991398
'', # empty line
14001399
]))
14011400

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

1405-
subdir = os.path.join(base_dir, 'node_modules', 'grunt-cli')
1404+
subdir = os.path.join(base_dir, 'ignored', 'subdir')
14061405
os.makedirs(subdir)
1407-
with open(os.path.join(subdir, 'grunt'), 'w') as f:
1408-
f.write("grunt")
1406+
with open(os.path.join(subdir, 'file'), 'w') as f:
1407+
f.write("this file should be ignored")
14091408

1410-
stream = self.client.build(path=base_dir, stream=True)
1411-
logs = ''
1409+
tag = 'docker-py-test-build-with-dockerignore'
1410+
stream = self.client.build(
1411+
path=base_dir,
1412+
tag=tag,
1413+
)
14121414
for chunk in stream:
1413-
if six.PY3:
1414-
chunk = chunk.decode('utf-8')
1415-
logs += chunk
1416-
self.assertFalse('node_modules' in logs)
1417-
self.assertFalse('Dockerfile' in logs)
1418-
self.assertFalse('.dockerginore' in logs)
1419-
self.assertTrue('not-ignored' in logs)
1415+
pass
1416+
1417+
c = self.client.create_container(tag, ['ls', '-1A', '/test'])
1418+
self.client.start(c)
1419+
self.client.wait(c)
1420+
logs = self.client.logs(c)
1421+
1422+
self.assertEqual(
1423+
filter(None, logs.split('\n')),
1424+
['not-ignored'],
1425+
)
14201426

14211427
#######################
14221428
# PY SPECIFIC TESTS #

0 commit comments

Comments
 (0)