(t *testing.T)
| 45 | } |
| 46 | |
| 47 | func TestOutputReturnsGitError(t *testing.T) { |
| 48 | // Given a command that fails with Git's not-a-repository diagnostic |
| 49 | stderr := "fatal: not a git repository (or any of the parent directories): .git" |
| 50 | cmd := createCommand(t, 128, "", stderr) |
| 51 | command := Command{cmd} |
| 52 | |
| 53 | // When its output is captured |
| 54 | out, err := command.Output() |
| 55 | |
| 56 | // Then the exit status and diagnostic are preserved in a Git error |
| 57 | require.Error(t, err) |
| 58 | var gitErr *GitError |
| 59 | require.ErrorAs(t, err, &gitErr) |
| 60 | assert.Equal(t, 128, gitErr.ExitCode) |
| 61 | assert.Equal(t, stderr, gitErr.Stderr) |
| 62 | require.EqualError(t, gitErr, "failed to run git: "+stderr) |
| 63 | assert.Empty(t, out) |
| 64 | } |
| 65 | |
| 66 | func TestWithRepoDirInsertsRepositoryBeforeGitArguments(t *testing.T) { |
| 67 | // Given a Git command with a final -C operand after the argument separator |
nothing calls this directly
no test coverage detected