mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-18 16:44:42 +04:00
Merge pull request #459 from bpicolo/docker_support
Docker hook support for pre-commit
This commit is contained in:
commit
6046b8bd7e
9 changed files with 157 additions and 3 deletions
15
tests/languages/docker_test.py
Normal file
15
tests/languages/docker_test.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import mock
|
||||
|
||||
from pre_commit.languages import docker
|
||||
from pre_commit.util import CalledProcessError
|
||||
|
||||
|
||||
def test_docker_is_running_process_error():
|
||||
with mock.patch(
|
||||
'pre_commit.languages.docker.cmd_output',
|
||||
side_effect=CalledProcessError(*(None,) * 4)
|
||||
):
|
||||
assert docker.docker_is_running() is False
|
||||
|
|
@ -29,6 +29,7 @@ from testing.fixtures import git_dir
|
|||
from testing.fixtures import make_config_from_repo
|
||||
from testing.fixtures import make_repo
|
||||
from testing.fixtures import modify_manifest
|
||||
from testing.util import skipif_cant_run_docker
|
||||
from testing.util import skipif_slowtests_false
|
||||
from testing.util import xfailif_no_pcre_support
|
||||
from testing.util import xfailif_windows_no_node
|
||||
|
|
@ -129,6 +130,29 @@ def test_versioned_python_hook(tempdir_factory, store):
|
|||
)
|
||||
|
||||
|
||||
@skipif_slowtests_false
|
||||
@skipif_cant_run_docker
|
||||
@pytest.mark.integration
|
||||
def test_run_a_docker_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'docker_hooks_repo',
|
||||
'docker-hook',
|
||||
['Hello World from docker'], b'Hello World from docker\n',
|
||||
)
|
||||
|
||||
|
||||
@skipif_slowtests_false
|
||||
@skipif_cant_run_docker
|
||||
@pytest.mark.integration
|
||||
def test_run_a_failing_docker_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'docker_hooks_repo',
|
||||
'docker-hook-failing',
|
||||
['Hello World from docker'], b'',
|
||||
expected_return_code=1
|
||||
)
|
||||
|
||||
|
||||
@skipif_slowtests_false
|
||||
@xfailif_windows_no_node
|
||||
@pytest.mark.integration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue