@@ -76,11 +76,12 @@ def test_uninstall(tmpdir_factory):
7676 assert not os .path .exists (runner .pre_commit_path )
7777
7878
79- def _get_commit_output (tmpdir_factory , touch_file = 'foo' ):
79+ def _get_commit_output (tmpdir_factory , touch_file = 'foo' , home = None ):
8080 local ['touch' ](touch_file )
8181 local ['git' ]('add' , touch_file )
8282 # Don't want to write to home directory
83- env = dict (os .environ , ** {'PRE_COMMIT_HOME' : tmpdir_factory .get ()})
83+ home = home or tmpdir_factory .get ()
84+ env = dict (os .environ , ** {'PRE_COMMIT_HOME' : home })
8485 return local ['git' ].run (
8586 ['commit' , '-m' , 'Commit!' , '--allow-empty' ],
8687 # git commit puts pre-commit to stderr
@@ -337,3 +338,26 @@ def test_uninstall_doesnt_remove_not_our_hooks(tmpdir_factory):
337338 assert uninstall (runner ) == 0
338339
339340 assert os .path .exists (runner .pre_commit_path )
341+
342+
343+ PRE_INSTALLED = re .compile (
344+ r'Bash hook\.+Passed\n'
345+ r'\[master [a-f0-9]{7}\] Commit!\n' +
346+ FILES_CHANGED +
347+ r' create mode 100644 foo\n$'
348+ )
349+
350+
351+ def test_installs_hooks_with_hooks_True (
352+ tmpdir_factory ,
353+ mock_out_store_directory ,
354+ ):
355+ path = make_consuming_repo (tmpdir_factory , 'script_hooks_repo' )
356+ with local .cwd (path ):
357+ install (Runner (path ), hooks = True )
358+ ret , output = _get_commit_output (
359+ tmpdir_factory , home = mock_out_store_directory ,
360+ )
361+
362+ assert ret == 0
363+ assert PRE_INSTALLED .match (output )
0 commit comments