Add -f, --follow flag as option on logs.
Closes #2187 Signed-off-by: Stéphane Seguin <stephseguin93@gmail.com>
This commit is contained in:
parent
c72e9b3843
commit
82632098a3
8 changed files with 64 additions and 17 deletions
|
|
@ -17,7 +17,7 @@ def build_mock_container(reader):
|
|||
name_without_project='web_1',
|
||||
has_api_logs=True,
|
||||
log_stream=None,
|
||||
attach=reader,
|
||||
logs=reader,
|
||||
wait=mock.Mock(return_value=0),
|
||||
)
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ def mock_container():
|
|||
class TestLogPrinter(object):
|
||||
|
||||
def test_single_container(self, output_stream, mock_container):
|
||||
LogPrinter([mock_container], output=output_stream).run()
|
||||
LogPrinter([mock_container], output=output_stream, follow=True).run()
|
||||
|
||||
output = output_stream.getvalue()
|
||||
assert 'hello' in output
|
||||
|
|
@ -47,6 +47,15 @@ class TestLogPrinter(object):
|
|||
# Call count is 2 lines + "container exited line"
|
||||
assert output_stream.flush.call_count == 3
|
||||
|
||||
def test_single_container_without_follow(self, output_stream, mock_container):
|
||||
LogPrinter([mock_container], output=output_stream, follow=False).run()
|
||||
|
||||
output = output_stream.getvalue()
|
||||
assert 'hello' in output
|
||||
assert 'world' in output
|
||||
# Call count is 2 lines
|
||||
assert output_stream.flush.call_count == 2
|
||||
|
||||
def test_monochrome(self, output_stream, mock_container):
|
||||
LogPrinter([mock_container], output=output_stream, monochrome=True).run()
|
||||
assert '\033[' not in output_stream.getvalue()
|
||||
|
|
@ -86,3 +95,4 @@ class TestLogPrinter(object):
|
|||
|
||||
output = output_stream.getvalue()
|
||||
assert "WARNING: no logs are available with the 'none' log driver\n" in output
|
||||
assert "exited with code" not in output
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class CLIMainTestCase(unittest.TestCase):
|
|||
mock_container('another', 1),
|
||||
]
|
||||
service_names = ['web', 'db']
|
||||
log_printer = build_log_printer(containers, service_names, True, False)
|
||||
log_printer = build_log_printer(containers, service_names, True, False, True)
|
||||
self.assertEqual(log_printer.containers, containers[:3])
|
||||
|
||||
def test_build_log_printer_all_services(self):
|
||||
|
|
@ -43,7 +43,7 @@ class CLIMainTestCase(unittest.TestCase):
|
|||
mock_container('other', 1),
|
||||
]
|
||||
service_names = []
|
||||
log_printer = build_log_printer(containers, service_names, True, False)
|
||||
log_printer = build_log_printer(containers, service_names, True, False, True)
|
||||
self.assertEqual(log_printer.containers, containers)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue