diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-03-03 07:55:30 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-03-03 07:55:30 +0100 |
| commit | a90ac1b352bd5f7c2c677f051365401531229976 (patch) | |
| tree | cc067d47265f058cbd9a6713f5506e2d0f757508 /tests | |
| parent | 0991aa7a4dfba90e895767e77676e7d29f9d1446 (diff) | |
| download | minishell_test-a90ac1b352bd5f7c2c677f051365401531229976.tar.gz minishell_test-a90ac1b352bd5f7c2c677f051365401531229976.tar.bz2 minishell_test-a90ac1b352bd5f7c2c677f051365401531229976.zip | |
Added test.result.Result tests for edge cases detected by code coverage, Added codecov
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test/test_result.py | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/tests/test/test_result.py b/tests/test/test_result.py index 7b29f66..f64511a 100644 --- a/tests/test/test_result.py +++ b/tests/test/test_result.py @@ -6,7 +6,7 @@ # By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2021/03/01 16:26:34 by cacharle #+# #+# # -# Updated: 2021/03/02 17:47:59 by cacharle ### ########.fr # +# Updated: 2021/03/03 07:53:09 by cacharle ### ########.fr # # # # ############################################################################ # @@ -102,6 +102,15 @@ class TestResult: ) @pytest.fixture + def result_fail_file_not_exist_expected(self): + return Result( + "echo bonjour", + ["foo"], + CapturedCommand("bonjour", 0, [None]), + CapturedCommand("bonjour", 0, ["bonjour"]), + ) + + @pytest.fixture def result_fail_file_multiple(self): return Result( "echo bonjour > foo > bar", @@ -114,29 +123,37 @@ class TestResult: def result_fail_timeout(self): return Result("echo bonjour", [], CapturedCommand("bonjour", 0, []), CapturedTimeout()) - def test_passed(self, result_pass, result_fail, result_fail_status, - result_fail_file, result_fail_file_not_exist, result_fail_file_multiple, result_fail_timeout): + @pytest.fixture + def result_pass_long_cmd(self): + return Result("e" * 300, [], CapturedCommand("", 0, []), CapturedCommand("", 0, [])) + + def test_passed(self, result_pass, result_fail, result_fail_status, result_fail_file, result_fail_file_not_exist, + result_fail_file_multiple, result_fail_timeout, result_fail_file_not_exist_expected, result_pass_long_cmd): assert result_pass.passed + assert result_pass_long_cmd.passed assert not result_fail.passed assert not result_fail_status.passed assert not result_fail_file.passed assert not result_fail_file_not_exist.passed assert not result_fail_file_multiple.passed assert not result_fail_timeout.passed + assert not result_fail_file_not_exist_expected.passed - def test_failed(self, result_pass, result_fail, result_fail_status, - result_fail_file, result_fail_file_not_exist, result_fail_file_multiple, result_fail_timeout): + def test_failed(self, result_pass, result_fail, result_fail_status, result_fail_file, result_fail_file_not_exist, + result_fail_file_multiple, result_fail_timeout, result_fail_file_not_exist_expected, result_pass_long_cmd): assert not result_pass.failed + assert not result_pass_long_cmd.failed assert result_fail.failed assert result_fail_status.failed assert result_fail_file.failed assert result_fail_file_not_exist.failed assert result_fail_file_multiple.failed assert result_fail_timeout.failed + assert result_fail_file_not_exist_expected.failed @pytest.mark.parametrize("term_cols", range(40, 300, 40)) - def test_summarize(self, result_pass, result_fail, result_fail_status, - result_fail_file, result_fail_file_not_exist, result_fail_timeout, term_cols): + def test_summarize(self, result_pass, result_fail, result_fail_status, result_fail_file, result_fail_file_not_exist, + result_fail_timeout, result_fail_file_not_exist_expected, result_pass_long_cmd, term_cols): with config_context(show_range=False, term_cols=term_cols): assert f"{'echo bonjour':{term_cols - 7}} [PASS]" == result_pass.summarize(-1) assert f"{'echo bonjour':{term_cols - 7}} [FAIL]" == result_fail.summarize(-1) @@ -144,6 +161,8 @@ class TestResult: assert f"{'echo bonjour > foo':{term_cols - 7}} [FAIL]" == result_fail_file.summarize(-1) assert f"{'echo bonjour > foo':{term_cols - 7}} [FAIL]" == result_fail_file_not_exist.summarize(-1) assert f"{'echo bonjour':{term_cols - 7}} [FAIL]" == result_fail_timeout.summarize(-1) + assert f"{'echo bonjour':{term_cols - 7}} [FAIL]" == result_fail_file_not_exist_expected.summarize(-1) + assert f"{('e' * 300)[:term_cols - 10]}... [PASS]" == result_pass_long_cmd.summarize(-1) with config_context(show_range=True, term_cols=term_cols): assert f" 1: {'echo bonjour':{term_cols - 11}} [PASS]" == result_pass.summarize(1) assert f" 1: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail.summarize(1) @@ -151,21 +170,27 @@ class TestResult: assert f" 1: {'echo bonjour > foo':{term_cols - 11}} [FAIL]" == result_fail_file.summarize(1) assert f" 1: {'echo bonjour > foo':{term_cols - 11}} [FAIL]" == result_fail_file_not_exist.summarize(1) assert f" 1: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_timeout.summarize(1) + assert f" 1: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_file_not_exist_expected.summarize(1) + assert f" 1: {('e' * 300)[:term_cols - 14]}... [PASS]" == result_pass_long_cmd.summarize(1) assert f"99: {'echo bonjour':{term_cols - 11}} [PASS]" == result_pass.summarize(99) assert f"99: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail.summarize(99) assert f"99: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_status.summarize(99) assert f"99: {'echo bonjour > foo':{term_cols - 11}} [FAIL]" == result_fail_file.summarize(99) assert f"99: {'echo bonjour > foo':{term_cols - 11}} [FAIL]" == result_fail_file_not_exist.summarize(99) assert f"99: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_timeout.summarize(99) + assert f"99: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_file_not_exist_expected.summarize(99) + assert f"99: {('e' * 300)[:term_cols - 14]}... [PASS]" == result_pass_long_cmd.summarize(99) assert f"100: {'echo bonjour':{term_cols - 12}} [PASS]" == result_pass.summarize(100) assert f"100: {'echo bonjour':{term_cols - 12}} [FAIL]" == result_fail.summarize(100) assert f"100: {'echo bonjour':{term_cols - 12}} [FAIL]" == result_fail_status.summarize(100) assert f"100: {'echo bonjour > foo':{term_cols - 12}} [FAIL]" == result_fail_file.summarize(100) assert f"100: {'echo bonjour > foo':{term_cols - 12}} [FAIL]" == result_fail_file_not_exist.summarize(100) assert f"100: {'echo bonjour':{term_cols - 12}} [FAIL]" == result_fail_timeout.summarize(100) + assert f"100: {'echo bonjour':{term_cols - 12}} [FAIL]" == result_fail_file_not_exist_expected.summarize(100) + assert f"100: {('e' * 300)[:term_cols - 15]}... [PASS]" == result_pass_long_cmd.summarize(100) - def test_repr(self, result_fail, result_fail_status, result_fail_file, - result_fail_file_not_exist, result_fail_file_multiple, result_fail_timeout): + def test_repr(self, result_fail, result_fail_status, result_fail_file, result_fail_file_not_exist, result_fail_file_multiple, + result_fail_timeout, result_fail_file_not_exist_expected): assert """\ |> WITH echo bonjour |----------------------------------------EXPECTED------------------------------- @@ -209,6 +234,14 @@ FROM TEST: File not created |> WITH echo bonjour TIMEOUT """ == result_fail_timeout.__repr__() + assert """\ +|> WITH echo bonjour +|# FILE foo +|----------------------------------------EXPECTED------------------------------- +FROM TEST: File not created +|----------------------------------------ACTUAL--------------------------------- +bonjour +""" == result_fail_file_not_exist_expected.__repr__() def test_expected_is_timeout(self): with pytest.raises(RuntimeError): |
