mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-17 22:40:11 -06:00
Add a test to validate that cfgv.WarnAdditionalKeys working as expected in the relevant config schemas
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user