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)
| 144 | // diffOutput is the fake diff content. gitRoot is the fake git root directory. |
| 145 | // Returns a cleanup function to restore the originals. |
| 146 | func 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 | |
| 158 | func captureCommitMsgOutput(t *testing.T) (string, error) { |
| 159 | t.Helper() |
no outgoing calls
no test coverage detected