@@ -40,6 +40,17 @@ def test_add_something_giant(temp_git_dir):
4040 assert find_large_added_files (['f.py' ], 10 ) == 0
4141
4242
43+ def test_enforce_all (temp_git_dir ):
44+ with temp_git_dir .as_cwd ():
45+ temp_git_dir .join ('f.py' ).write ('a' * 10000 )
46+
47+ # Should fail, when not staged with enforce_all
48+ assert find_large_added_files (['f.py' ], 0 , enforce_all = True ) == 1
49+
50+ # Should pass, when not staged without enforce_all
51+ assert find_large_added_files (['f.py' ], 0 , enforce_all = False ) == 0
52+
53+
4354def test_added_file_not_in_pre_commits_list (temp_git_dir ):
4455 with temp_git_dir .as_cwd ():
4556 temp_git_dir .join ('f.py' ).write ("print('hello world')" )
@@ -97,3 +108,15 @@ def test_moves_with_gitlfs(temp_git_dir, monkeypatch): # pragma: no cover
97108 # Now move it and make sure the hook still succeeds
98109 cmd_output ('git' , 'mv' , 'a.bin' , 'b.bin' )
99110 assert main (('--maxkb' , '9' , 'b.bin' )) == 0
111+
112+
113+ @xfailif_no_gitlfs
114+ def test_enforce_allows_gitlfs (temp_git_dir , monkeypatch ): # pragma: no cover
115+ with temp_git_dir .as_cwd ():
116+ monkeypatch .setenv ('HOME' , str (temp_git_dir ))
117+ cmd_output ('git' , 'lfs' , 'install' )
118+ temp_git_dir .join ('f.py' ).write ('a' * 10000 )
119+ cmd_output ('git' , 'lfs' , 'track' , 'f.py' )
120+ cmd_output ('git' , 'add' , '--' , '.' )
121+ # With --enforce-all large files on git lfs should succeed
122+ assert main (('--enforce-all' , '--maxkb' , '9' , 'f.py' )) == 0
0 commit comments