Add -f, --follow flag as option on logs.

Closes #2187
Signed-off-by: Stéphane Seguin <stephseguin93@gmail.com>
This commit is contained in:
Stéphane Seguin 2016-01-21 13:16:04 +01:00
commit 82632098a3
8 changed files with 64 additions and 17 deletions

View file

@ -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