MCPcopy Create free account
hub / github.com/dirk/quickhook / TestHookMutatesCommitMsg

Function TestHookMutatesCommitMsg

hooks/commit_msg_test.go:27–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25}
26
27func TestHookMutatesCommitMsg(t *testing.T) {
28 tempDir := initGitForCommitMsg(t)
29 tempDir.MkdirAll(".quickhook", "commit-msg")
30 tempDir.WriteFile(
31 []string{".quickhook", "commit-msg", "appends"},
32 // -n makes echo not emit a trailing newline.
33 "#!/bin/bash \n echo -n \" second\" >> $1")
34
35 editMsgFile := writeCommitEditMsg(t, "First")
36 _, err := tempDir.ExecQuickhook("hook", "commit-msg", editMsgFile)
37 assert.NoError(t, err)
38
39 newEditMsg, err := os.ReadFile(editMsgFile)
40 assert.NoError(t, err)
41 assert.Equal(t, "First second", string(newEditMsg))
42}
43
44func TestFailingHook(t *testing.T) {
45 tempDir := initGitForCommitMsg(t)

Callers

nothing calls this directly

Calls 5

initGitForCommitMsgFunction · 0.85
writeCommitEditMsgFunction · 0.85
MkdirAllMethod · 0.80
WriteFileMethod · 0.80
ExecQuickhookMethod · 0.80

Tested by

no test coverage detected