MCPcopy Create free account
hub / github.com/driangle/taskmd / mockGitDiffAndRoot

Function mockGitDiffAndRoot

apps/cli/internal/cli/commit_msg_test.go:146–156  ·  view source on GitHub ↗

mockGitDiffAndRoot sets up gitDiffFunc and gitRootFunc for tests. diffOutput is the fake diff content. gitRoot is the fake git root directory. Returns a cleanup function to restore the originals.

(t *testing.T, diffOutput string, gitRoot string)

Source from the content-addressed store, hash-verified

144// diffOutput is the fake diff content. gitRoot is the fake git root directory.
145// Returns a cleanup function to restore the originals.
146func mockGitDiffAndRoot(t *testing.T, diffOutput string, gitRoot string) {
147 t.Helper()
148 oldDiff := gitDiffFunc
149 oldRoot := gitRootFunc
150 gitDiffFunc = func(_ string) (string, error) { return diffOutput, nil }
151 gitRootFunc = func(_ string) (string, error) { return gitRoot, nil }
152 t.Cleanup(func() {
153 gitDiffFunc = oldDiff
154 gitRootFunc = oldRoot
155 })
156}
157
158func captureCommitMsgOutput(t *testing.T) (string, error) {
159 t.Helper()

Calls

no outgoing calls

Tested by

no test coverage detected