[gitfame] Fix HEAD ref test.

This commit is contained in:
Arseny Balobanov 2021-03-03 18:44:16 +03:00
parent dea3d9fd4e
commit 188819ffa5

View file

@ -60,14 +60,14 @@ func TestGitFame(t *testing.T) {
if !tc.Error { if !tc.Error {
require.NoError(t, err) require.NoError(t, err)
CompareResults(t, tc.Expected, output, tc.Format) CompareResults(t, tc.Expected, output, tc.Format)
newHEADRef := GetHEADRef(t, dir)
require.Equal(t, headRef, newHEADRef)
} else { } else {
require.Error(t, err) require.Error(t, err)
_, ok := err.(*exec.ExitError) _, ok := err.(*exec.ExitError)
require.True(t, ok) require.True(t, ok)
} }
newHEADRef := GetHEADRef(t, dir)
require.Equal(t, headRef, newHEADRef)
}) })
} }
} }
@ -182,7 +182,7 @@ func ParseJSONLines(data []byte) [][]byte {
func GetHEADRef(t *testing.T, path string) string { func GetHEADRef(t *testing.T, path string) string {
t.Helper() t.Helper()
cmd := exec.Command("git", "show-ref", "HEAD") cmd := exec.Command("git", "rev-parse", "HEAD")
cmd.Dir = path cmd.Dir = path
out, err := cmd.Output() out, err := cmd.Output()