mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add a test to validate that cfgv.WarnAdditionalKeys working as expected in the relevant config schemas
This commit is contained in:
parent
217d31ec1c
commit
ba7760b705
2 changed files with 19 additions and 1 deletions
|
|
@ -109,6 +109,8 @@ META = 'meta'
|
|||
|
||||
|
||||
class MigrateShaToRev(object):
|
||||
key = 'rev'
|
||||
|
||||
@staticmethod
|
||||
def _cond(key):
|
||||
return cfgv.Conditional(
|
||||
|
|
@ -263,7 +265,14 @@ CONFIG_SCHEMA = cfgv.Map(
|
|||
'0',
|
||||
),
|
||||
cfgv.WarnAdditionalKeys(
|
||||
('repos',),
|
||||
(
|
||||
'repos',
|
||||
'default_language_version',
|
||||
'default_stages',
|
||||
'exclude',
|
||||
'fail_fast',
|
||||
'minimum_pre_commit_version',
|
||||
),
|
||||
warn_on_unknown_keys_at_top_level,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -305,3 +305,12 @@ def test_minimum_pre_commit_version_failing():
|
|||
def test_minimum_pre_commit_version_passing():
|
||||
cfg = {'repos': [], 'minimum_pre_commit_version': '0'}
|
||||
cfgv.validate(cfg, CONFIG_SCHEMA)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('schema', (CONFIG_SCHEMA, CONFIG_REPO_DICT))
|
||||
def test_warn_additional(schema):
|
||||
allowed_keys = {item.key for item in schema.items if hasattr(item, 'key')}
|
||||
warn_additional, = [
|
||||
x for x in schema.items if isinstance(x, cfgv.WarnAdditionalKeys)
|
||||
]
|
||||
assert allowed_keys == set(warn_additional.keys)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue