diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-04-28 05:31:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-04-28 05:31:41 +0000 |
commit | 4825c90b8299e0ee4ee27c2529820bad8b64c3b1 (patch) | |
tree | 0362830820537da5f1764d96e88ab8d2e7227827 /tests/commands/autoupdate_test.py | |
parent | Releasing debian version 2.2.0-2. (diff) | |
download | pre-commit-4825c90b8299e0ee4ee27c2529820bad8b64c3b1.tar.xz pre-commit-4825c90b8299e0ee4ee27c2529820bad8b64c3b1.zip |
Merging upstream version 2.3.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/commands/autoupdate_test.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/commands/autoupdate_test.py b/tests/commands/autoupdate_test.py index 2c7b2f1..25161d1 100644 --- a/tests/commands/autoupdate_test.py +++ b/tests/commands/autoupdate_test.py @@ -263,6 +263,45 @@ def test_does_not_reformat(tmpdir, out_of_date, store): assert cfg.read() == expected +def test_does_not_change_mixed_endlines_read(up_to_date, tmpdir, store): + fmt = ( + 'repos:\n' + '- repo: {}\n' + ' rev: {} # definitely the version I want!\r\n' + ' hooks:\r\n' + ' - id: foo\n' + ' # These args are because reasons!\r\n' + ' args: [foo, bar, baz]\r\n' + ) + cfg = tmpdir.join(C.CONFIG_FILE) + + expected = fmt.format(up_to_date, git.head_rev(up_to_date)).encode() + cfg.write_binary(expected) + + assert autoupdate(str(cfg), store, freeze=False, tags_only=False) == 0 + assert cfg.read_binary() == expected + + +def test_does_not_change_mixed_endlines_write(tmpdir, out_of_date, store): + fmt = ( + 'repos:\n' + '- repo: {}\n' + ' rev: {} # definitely the version I want!\r\n' + ' hooks:\r\n' + ' - id: foo\n' + ' # These args are because reasons!\r\n' + ' args: [foo, bar, baz]\r\n' + ) + cfg = tmpdir.join(C.CONFIG_FILE) + cfg.write_binary( + fmt.format(out_of_date.path, out_of_date.original_rev).encode(), + ) + + assert autoupdate(str(cfg), store, freeze=False, tags_only=False) == 0 + expected = fmt.format(out_of_date.path, out_of_date.head_rev).encode() + assert cfg.read_binary() == expected + + def test_loses_formatting_when_not_detectable(out_of_date, store, tmpdir): """A best-effort attempt is made at updating rev without rewriting formatting. When the original formatting cannot be detected, this |