From 3b8aa606c15c167ce4ed60fc475f78ca0e58540f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alvaro=20Andr=C3=A9s=20Rodr=C3=ADguez=20Scelza?= Date: Tue, 4 Jun 2019 12:47:51 -0300 Subject: [PATCH] coverage report command does not need to specify ignoring 100% files: it's already specified in coverage conf file. branch name checker tests ready at 100% --- .../Documentation/automatic_testing.txt | 2 +- .../check_branch_name_test.py | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 pre_commit_hooks/loaderon_hooks/tests/automatic_testing/check_branch_name_test.py diff --git a/pre_commit_hooks/loaderon_hooks/Documentation/automatic_testing.txt b/pre_commit_hooks/loaderon_hooks/Documentation/automatic_testing.txt index 5933dfe..990c754 100644 --- a/pre_commit_hooks/loaderon_hooks/Documentation/automatic_testing.txt +++ b/pre_commit_hooks/loaderon_hooks/Documentation/automatic_testing.txt @@ -3,7 +3,7 @@ ALL pre_commit_hooks tests, not only Loaderon's): coverage erase coverage run --source pre_commit_hooks -m pytest -coverage report --fail-under 100 +coverage report ####################################################################################################################### diff --git a/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/check_branch_name_test.py b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/check_branch_name_test.py new file mode 100644 index 0000000..1fb89db --- /dev/null +++ b/pre_commit_hooks/loaderon_hooks/tests/automatic_testing/check_branch_name_test.py @@ -0,0 +1,37 @@ +import subprocess +import sys +import uuid + +import pytest + +from pre_commit_hooks.loaderon_hooks.general_hooks.check_branch_name import main + + +@pytest.fixture(autouse=True) +def clean_sys_argv(): + sys.argv = [] + yield + + +def test_branch_name_ok(): + new_branch_name = str(uuid.uuid4()) + subprocess.check_output(['git', 'checkout', '-b', new_branch_name]) + sys.argv.append('--regex') + sys.argv.append(r'\b(?!master)\b\S+') + + result = main(sys.argv) + + subprocess.check_output(['git', 'checkout', 'master']) + subprocess.check_output(['git', 'branch', '-d', new_branch_name]) + + assert result == 0 + + +def test_branch_name_error(): + subprocess.check_output(['git', 'checkout', 'master']) + sys.argv.append('--regex') + sys.argv.append(r'\b(?!master)\b\S+') + + result = main(sys.argv) + + assert result == 2