diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-04-28 05:31:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-04-28 05:31:41 +0000 |
commit | 4825c90b8299e0ee4ee27c2529820bad8b64c3b1 (patch) | |
tree | 0362830820537da5f1764d96e88ab8d2e7227827 /tests/languages | |
parent | Releasing debian version 2.2.0-2. (diff) | |
download | pre-commit-4825c90b8299e0ee4ee27c2529820bad8b64c3b1.tar.xz pre-commit-4825c90b8299e0ee4ee27c2529820bad8b64c3b1.zip |
Merging upstream version 2.3.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/languages/docker_test.py | 2 | ||||
-rw-r--r-- | tests/languages/node_test.py | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/languages/docker_test.py b/tests/languages/docker_test.py index 171a3f7..b65b223 100644 --- a/tests/languages/docker_test.py +++ b/tests/languages/docker_test.py @@ -20,4 +20,4 @@ def test_docker_fallback_user(): getuid=invalid_attribute, getgid=invalid_attribute, ): - assert docker.get_docker_user() == '1000:1000' + assert docker.get_docker_user() == () diff --git a/tests/languages/node_test.py b/tests/languages/node_test.py new file mode 100644 index 0000000..fd30046 --- /dev/null +++ b/tests/languages/node_test.py @@ -0,0 +1,47 @@ +import sys +from unittest import mock + +import pytest + +import pre_commit.constants as C +from pre_commit import parse_shebang +from pre_commit.languages.node import get_default_version + + +ACTUAL_GET_DEFAULT_VERSION = get_default_version.__wrapped__ + + +@pytest.fixture +def is_linux(): + with mock.patch.object(sys, 'platform', 'linux'): + yield + + +@pytest.fixture +def is_win32(): + with mock.patch.object(sys, 'platform', 'win32'): + yield + + +@pytest.fixture +def find_exe_mck(): + with mock.patch.object(parse_shebang, 'find_executable') as mck: + yield mck + + +@pytest.mark.usefixtures('is_linux') +def test_sets_system_when_node_and_npm_are_available(find_exe_mck): + find_exe_mck.return_value = '/path/to/exe' + assert ACTUAL_GET_DEFAULT_VERSION() == 'system' + + +@pytest.mark.usefixtures('is_linux') +def test_uses_default_when_node_and_npm_are_not_available(find_exe_mck): + find_exe_mck.return_value = None + assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT + + +@pytest.mark.usefixtures('is_win32') +def test_sets_default_on_windows(find_exe_mck): + find_exe_mck.return_value = '/path/to/exe' + assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT |