Skip to content

Commit d71bdd1

Browse files
author
Jordan Webb
committed
Add buildah test and stub
1 parent 1a02a86 commit d71bdd1

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/buildah_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
3+
import mitogen
4+
5+
import unittest2
6+
7+
import testlib
8+
9+
10+
class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
11+
def test_okay(self):
12+
buildah_path = testlib.data_path('stubs/stub-buildah.py')
13+
context = self.router.buildah(
14+
container='container_name',
15+
buildah_path=buildah_path,
16+
)
17+
stream = self.router.stream_by_id(context.context_id)
18+
19+
argv = eval(context.call(os.getenv, 'ORIGINAL_ARGV'))
20+
self.assertEquals(argv[0], buildah_path)
21+
self.assertEquals(argv[1], 'run')
22+
self.assertEquals(argv[2], '--')
23+
self.assertEquals(argv[3], 'container_name')
24+
self.assertEquals(argv[4], stream.python_path)
25+
26+
27+
if __name__ == '__main__':
28+
unittest2.main()

tests/data/stubs/stub-buildah.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
import os
5+
6+
os.environ['ORIGINAL_ARGV'] = repr(sys.argv)
7+
os.environ['THIS_IS_STUB_BUILDAH'] = '1'
8+
os.execv(sys.executable, sys.argv[sys.argv.index('--') + 2:])

0 commit comments

Comments
 (0)