@@ -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
@@ -336,3 +337,26 @@ def test_uninstall_doesnt_remove_not_our_hooks(tmpdir_factory):
336337 assert uninstall (runner ) == 0
337338
338339 assert os .path .exists (runner .pre_commit_path )
340+
341+
342+ PRE_INSTALLED = re .compile (
343+ r'Bash hook\.+Passed\n'
344+ r'\[master [a-f0-9]{7}\] Commit!\n' +
345+ FILES_CHANGED +
346+ r' create mode 100644 foo\n$'
347+ )
348+
349+
350+ def test_installs_hooks_with_hooks_True (
351+ tmpdir_factory ,
352+ mock_out_store_directory ,
353+ ):
354+ path = make_consuming_repo (tmpdir_factory , 'script_hooks_repo' )
355+ with local .cwd (path ):
356+ install (Runner (path ), hooks = True )
357+ ret , output = _get_commit_output (
358+ tmpdir_factory , home = mock_out_store_directory ,
359+ )
360+
361+ assert ret == 0
362+ assert PRE_INSTALLED .match (output )
0 commit comments