shimGit puts a fake `git` at the front of PATH for the duration of the test.
(t *testing.T, body string)
| 157 | |
| 158 | // shimGit puts a fake `git` at the front of PATH for the duration of the test. |
| 159 | func shimGit(t *testing.T, body string) { |
| 160 | t.Helper() |
| 161 | if runtime.GOOS == "windows" { |
| 162 | t.Skip("PATH shim relies on a shebang script") |
| 163 | } |
| 164 | dir := t.TempDir() |
| 165 | if err := os.WriteFile(filepath.Join(dir, "git"), []byte("#!/bin/sh\n"+body), 0o755); err != nil { |
| 166 | t.Fatalf("write git shim: %v", err) |
| 167 | } |
| 168 | t.Setenv("PATH", dir+string(os.PathListSeparator)+os.Getenv("PATH")) |
| 169 | } |
| 170 | |
| 171 | // TestGetDiff_FailureQuotesStderrNotStdout pins the split that keeps repository |
| 172 | // content out of the error. |
no outgoing calls
no test coverage detected