mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix autoupdate spamming with defaults.
This commit is contained in:
parent
817ec510c7
commit
8b5c3b8745
4 changed files with 68 additions and 12 deletions
|
|
@ -120,6 +120,12 @@ def test_out_of_date_repo(out_of_date_repo):
|
|||
assert ret['sha'] == out_of_date_repo.head_sha
|
||||
|
||||
|
||||
def test_removes_defaults(out_of_date_repo):
|
||||
ret = _update_repository(out_of_date_repo.repo_config)
|
||||
assert 'args' not in ret['hooks'][0]
|
||||
assert 'expected_return_value' not in ret['hooks'][0]
|
||||
|
||||
|
||||
def test_autoupdate_out_of_date_repo(out_of_date_repo):
|
||||
before = open(C.CONFIG_FILE).read()
|
||||
runner = Runner(out_of_date_repo.python_hooks_repo)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from pre_commit.jsonschema_extensions import apply_defaults
|
||||
from pre_commit.jsonschema_extensions import remove_defaults
|
||||
|
||||
|
||||
def test_apply_defaults_copies_object():
|
||||
|
|
@ -56,3 +57,25 @@ def test_apply_defaults_copies():
|
|||
ret1 = apply_defaults({}, schema)
|
||||
ret2 = apply_defaults({}, schema)
|
||||
assert ret1['foo'] is not ret2['foo']
|
||||
|
||||
|
||||
def test_remove_defaults_copies_object():
|
||||
input = {}
|
||||
ret = remove_defaults(input, {})
|
||||
assert ret is not input
|
||||
|
||||
|
||||
def test_remove_defaults_does_not_remove_non_default():
|
||||
ret = remove_defaults(
|
||||
{'foo': 'bar'},
|
||||
{'properties': {'foo': {'default': 'baz'}}},
|
||||
)
|
||||
assert ret == {'foo': 'bar'}
|
||||
|
||||
|
||||
def test_remove_defaults_removes_default():
|
||||
ret = remove_defaults(
|
||||
{'foo': 'bar'},
|
||||
{'properties': {'foo': {'default': 'bar'}}},
|
||||
)
|
||||
assert ret == {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue