mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-01 10:56:52 +00:00
Add check-yaml-filename-extension hook
This commit is contained in:
parent
5420c705a4
commit
1ea1ff2061
5 changed files with 66 additions and 0 deletions
26
tests/check_yaml_filename_extension_test.py
Normal file
26
tests/check_yaml_filename_extension_test.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from pre_commit_hooks.check_yaml_filename_extension import main
|
||||
from pre_commit_hooks.util import cmd_output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('filename', 'new_filename', 'expected_retval'), (
|
||||
('file_1.yml', 'file_1.yaml', 1),
|
||||
('.file_2.yml', '.file_2.yaml', 1),
|
||||
('file_3.yaml', 'file_3.yaml', 0),
|
||||
),
|
||||
)
|
||||
def test_main(temp_git_dir, filename, new_filename, expected_retval):
|
||||
with temp_git_dir.as_cwd():
|
||||
temp_git_dir.join(filename).write('---')
|
||||
cmd_output('git', 'add', filename)
|
||||
|
||||
retv = main([filename])
|
||||
|
||||
assert retv == expected_retval
|
||||
assert temp_git_dir.join(new_filename).exists()
|
||||
|
||||
assert retv == 0 or not temp_git_dir.join(filename).exists()
|
||||
Loading…
Add table
Add a link
Reference in a new issue