Write integration tests on new `fig run` linking behaviour

Signed-off-by: Chris Corbyn <chris@w3style.co.uk>
This commit is contained in:
d11wtq 2014-06-08 13:03:58 +00:00 committed by Chris Corbyn
parent 94a3164248
commit 655d347ea2
1 changed files with 24 additions and 0 deletions

View File

@ -4,14 +4,18 @@ from .testcases import DockerClientTestCase
from mock import patch from mock import patch
from fig.cli.main import TopLevelCommand from fig.cli.main import TopLevelCommand
from fig.packages.six import StringIO from fig.packages.six import StringIO
import sys
class CLITestCase(DockerClientTestCase): class CLITestCase(DockerClientTestCase):
def setUp(self): def setUp(self):
super(CLITestCase, self).setUp() super(CLITestCase, self).setUp()
self.old_sys_exit = sys.exit
sys.exit = lambda code=0: None
self.command = TopLevelCommand() self.command = TopLevelCommand()
self.command.base_dir = 'tests/fixtures/simple-figfile' self.command.base_dir = 'tests/fixtures/simple-figfile'
def tearDown(self): def tearDown(self):
sys.exit = self.old_sys_exit
self.command.project.kill() self.command.project.kill()
self.command.project.remove_stopped() self.command.project.remove_stopped()
@ -70,6 +74,26 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual(len(db.containers()), 0) self.assertEqual(len(db.containers()), 0)
self.assertEqual(len(console.containers()), 0) self.assertEqual(len(console.containers()), 0)
@patch('sys.stdout', new_callable=StringIO)
def test_run_with_links(self, mock_stdout):
mock_stdout.fileno = lambda: 1
self.command.base_dir = 'tests/fixtures/links-figfile'
self.command.dispatch([str('run'), str('web'), str('/bin/true')], None)
db = self.command.project.get_service('db')
console = self.command.project.get_service('console')
self.assertEqual(len(db.containers()), 1)
self.assertEqual(len(console.containers()), 0)
@patch('sys.stdout', new_callable=StringIO)
def test_run_with_no_links(self, mock_stdout):
mock_stdout.fileno = lambda: 1
self.command.base_dir = 'tests/fixtures/links-figfile'
self.command.dispatch([str('run'), str('--no-links'), str('web'), str('/bin/true')], None)
db = self.command.project.get_service('db')
self.assertEqual(len(db.containers()), 0)
def test_rm(self): def test_rm(self):
service = self.command.project.get_service('simple') service = self.command.project.get_service('simple')
service.create_container() service.create_container()