-
Notifications
You must be signed in to change notification settings - Fork 911
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle error when log file is empty (#4859)
Fixes GH-4686
- Loading branch information
1 parent
a39ef2d
commit b4fb02c
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from collections import namedtuple | ||
|
||
import pytest | ||
|
||
from cloudinit.analyze import analyze_show | ||
|
||
|
||
@pytest.fixture | ||
def mock_io(tmp_path): | ||
"""Mock args for configure_io function""" | ||
infile = tmp_path / "infile" | ||
outfile = tmp_path / "outfile" | ||
return namedtuple("MockIO", ["infile", "outfile"])(infile, outfile) | ||
|
||
|
||
class TestAnalyzeShow: | ||
"""Test analyze_show (and/or helpers) in cloudinit/analyze/__init__.py""" | ||
|
||
def test_empty_logfile(self, mock_io, capsys): | ||
"""Test analyze_show with an empty logfile""" | ||
mock_io.infile.write_text("") | ||
with pytest.raises(SystemExit): | ||
analyze_show("dontcare", mock_io) | ||
assert capsys.readouterr().err == f"Empty file {mock_io.infile}\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ ajmyyra | |
akutz | ||
AlexBaranowski | ||
AlexSv04047 | ||
AliyevH | ||
Aman306 | ||
andgein | ||
andrew-lee-metaswitch | ||
|