Skip to content

Commit

Permalink
Add negative test cases for various git artifacts.
Browse files Browse the repository at this point in the history
  • Loading branch information
christhekeele committed Apr 11, 2021
1 parent 8993f10 commit 0c6a81a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pre_commit_hooks/check_merge_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
CONFLICT_PATTERNS = [
b'<<<<<<< ',
b'======= ',
b'||||||| ',
b'=======\n',
b'||||||| ',
b'|||||||\n',
b'>>>>>>> ',
]

Expand Down
24 changes: 24 additions & 0 deletions tests/check_merge_conflict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,32 @@ def test_does_not_care_when_not_in_a_merge(tmpdir):
f.write_binary(b'problem\n=======\n')
assert main([str(f.realpath())]) == 0

f = tmpdir.join('README.md')
f.write_binary(b'problem\n======= \n')
assert main([str(f.realpath())]) == 0

f = tmpdir.join('README.md')
f.write_binary(b'problem\n|||||||\n')
assert main([str(f.realpath()), '--assume-in-merge']) == 0

f = tmpdir.join('README.md')
f.write_binary(b'problem\n||||||| \n')
assert main([str(f.realpath()), '--assume-in-merge']) == 0


def test_care_when_assumed_merge(tmpdir):
f = tmpdir.join('README.md')
f.write_binary(b'problem\n=======\n')
assert main([str(f.realpath()), '--assume-in-merge']) == 1

f = tmpdir.join('README.md')
f.write_binary(b'problem\n======= \n')
assert main([str(f.realpath()), '--assume-in-merge']) == 1

f = tmpdir.join('README.md')
f.write_binary(b'problem\n|||||||\n')
assert main([str(f.realpath()), '--assume-in-merge']) == 1

f = tmpdir.join('README.md')
f.write_binary(b'problem\n||||||| \n')
assert main([str(f.realpath()), '--assume-in-merge']) == 1

0 comments on commit 0c6a81a

Please sign in to comment.