mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Improve coverage for validators.
This commit is contained in:
parent
cd36e9e779
commit
0fec434380
2 changed files with 26 additions and 20 deletions
|
|
@ -6,18 +6,21 @@ from pre_commit.clientlib.validate_config import run
|
||||||
from pre_commit.clientlib.validate_config import validate_config_extra
|
from pre_commit.clientlib.validate_config import validate_config_extra
|
||||||
from pre_commit.jsonschema_extensions import apply_defaults
|
from pre_commit.jsonschema_extensions import apply_defaults
|
||||||
from testing.util import is_valid_according_to_schema
|
from testing.util import is_valid_according_to_schema
|
||||||
|
from testing.util import get_resource_path
|
||||||
|
|
||||||
|
|
||||||
def test_returns_0_for_valid_config():
|
@pytest.mark.parametrize(
|
||||||
assert run(['example_pre-commit-config.yaml']) == 0
|
('input', 'expected_output'),
|
||||||
|
(
|
||||||
|
(['example_pre-commit-config.yaml'], 0),
|
||||||
def test_returns_0_for_out_manifest():
|
(['.pre-commit-config.yaml'], 0),
|
||||||
assert run([]) == 0
|
(['non_existent_file.yaml'], 1),
|
||||||
|
([get_resource_path('valid_yaml_but_invalid_config.yaml')], 1),
|
||||||
|
([get_resource_path('non_parseable_yaml_file.notyaml')], 1),
|
||||||
def test_returns_1_for_failing():
|
),
|
||||||
assert run(['tests/data/valid_yaml_but_invalid_config.yaml']) == 1
|
)
|
||||||
|
def test_run(input, expected_output):
|
||||||
|
assert run(input) == expected_output
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(('manifest_obj', 'expected'), (
|
@pytest.mark.parametrize(('manifest_obj', 'expected'), (
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,21 @@ from pre_commit.clientlib.validate_manifest import InvalidManifestError
|
||||||
from pre_commit.clientlib.validate_manifest import MANIFEST_JSON_SCHEMA
|
from pre_commit.clientlib.validate_manifest import MANIFEST_JSON_SCHEMA
|
||||||
from pre_commit.clientlib.validate_manifest import run
|
from pre_commit.clientlib.validate_manifest import run
|
||||||
from testing.util import is_valid_according_to_schema
|
from testing.util import is_valid_according_to_schema
|
||||||
|
from testing.util import get_resource_path
|
||||||
|
|
||||||
|
|
||||||
def test_returns_0_for_valid_manifest():
|
@pytest.mark.parametrize(
|
||||||
assert run(['example_hooks.yaml']) == 0
|
('input', 'expected_output'),
|
||||||
|
(
|
||||||
|
(['example_hooks.yaml'], 0),
|
||||||
def test_returns_0_for_our_manifest():
|
(['hooks.yaml'], 0),
|
||||||
assert run([]) == 0
|
(['non_existent_file.yaml'], 1),
|
||||||
|
([get_resource_path('valid_yaml_but_invalid_manifest.yaml')], 1),
|
||||||
|
([get_resource_path('non_parseable_yaml_file.notyaml')], 1),
|
||||||
def test_returns_1_for_failing():
|
),
|
||||||
assert run(['tests/data/valid_yaml_but_invalid_manifest.yaml']) == 1
|
)
|
||||||
|
def test_run(input, expected_output):
|
||||||
|
assert run(input) == expected_output
|
||||||
|
|
||||||
|
|
||||||
def test_additional_manifest_check_raises_for_bad_language():
|
def test_additional_manifest_check_raises_for_bad_language():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue