-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitexec_test.go
More file actions
36 lines (30 loc) · 1.09 KB
/
gitexec_test.go
File metadata and controls
36 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
func TestExecGitNoMergeBaseDiagnosticIsGeneric(t *testing.T) {
t.Parallel()
requireGit(t)
repoRoot := t.TempDir()
runGit(t, repoRoot, "init")
runGit(t, repoRoot, "config", "user.email", "test@example.com")
runGit(t, repoRoot, "config", "user.name", "Test User")
writeTestFile(t, repoRoot, "pkg/sample_test.go", `package sample
`)
runGit(t, repoRoot, "add", ".")
runGit(t, repoRoot, "commit", "-m", "base")
runGit(t, repoRoot, "branch", "left")
runGit(t, repoRoot, "checkout", "--orphan", "right")
require.NoError(t, os.Remove(filepath.Join(repoRoot, "pkg", "sample_test.go")))
writeTestFile(t, repoRoot, "pkg/sample_test.go", `package sample
`)
runGit(t, repoRoot, "add", ".")
runGit(t, repoRoot, "commit", "-m", "right")
_, err := execGit(t.Context(), repoRoot, "diff", "left...right", "--", "pkg/sample_test.go")
require.Error(t, err)
require.ErrorContains(t, err, "Ensure both revisions have full history before diffing")
require.NotContains(t, err.Error(), `diffing "pkg/sample_test.go"`)
}