Remove defaults from pre-commit config schema. Resolves #227

This commit is contained in:
Anthony Sottile 2015-05-18 12:46:10 -07:00
parent 9515ca0637
commit 039a7a5878
5 changed files with 36 additions and 4 deletions

View file

@ -174,3 +174,23 @@ def test_config_with_local_hooks_definition_passes(config_obj):
jsonschema.validate(config_obj, CONFIG_JSON_SCHEMA)
config = apply_defaults(config_obj, CONFIG_JSON_SCHEMA)
validate_config_extra(config)
def test_does_not_contain_defaults():
"""Due to the way our merging works, if this schema has any defaults they
will clobber potentially useful values in the backing manifest. #227
"""
to_process = [(CONFIG_JSON_SCHEMA, ())]
while to_process:
schema, route = to_process.pop()
# Check this value
if isinstance(schema, dict):
if 'default' in schema:
raise AssertionError(
'Unexpected default in schema at {0}'.format(
' => '.join(route),
)
)
for key, value in schema.items():
to_process.append((value, route + (key,)))

View file

@ -46,6 +46,9 @@ def test_additional_manifest_check_passing(obj):
[{'id': 'a', 'language': 'not a language', 'files': ''}],
[{'id': 'a', 'language': 'python3', 'files': ''}],
[{'id': 'a', 'language': 'python', 'files': 'invalid regex('}],
[{'id': 'a', 'language': 'not a language', 'files': ''}],
[{'id': 'a', 'language': 'python3', 'files': ''}],
[{'id': 'a', 'language': 'python', 'files': '', 'exclude': '('}],
),
)
def test_additional_manifest_failing(obj):

View file

@ -22,6 +22,7 @@ def test_manifest_contents(manifest):
'args': [],
'description': '',
'entry': 'bin/hook.sh',
'exclude': '^$',
'expected_return_value': 0,
'files': '',
'id': 'bash_hook',
@ -36,6 +37,7 @@ def test_hooks(manifest):
'args': [],
'description': '',
'entry': 'bin/hook.sh',
'exclude': '^$',
'expected_return_value': 0,
'files': '',
'id': 'bash_hook',