[gitfame] Fix HEAD ref test.
This commit is contained in:
parent
976cc94007
commit
98c6403f7b
1 changed files with 6 additions and 3 deletions
|
@ -51,7 +51,7 @@ func TestGitFame(t *testing.T) {
|
||||||
args = append(args, tc.Args...)
|
args = append(args, tc.Args...)
|
||||||
|
|
||||||
Unbundle(t, filepath.Join(bundlesDir, tc.Bundle), dir)
|
Unbundle(t, filepath.Join(bundlesDir, tc.Bundle), dir)
|
||||||
headRef := GetHEADRef(t)
|
headRef := GetHEADRef(t, dir)
|
||||||
|
|
||||||
cmd := exec.Command(binary, args...)
|
cmd := exec.Command(binary, args...)
|
||||||
cmd.Stderr = ioutil.Discard
|
cmd.Stderr = ioutil.Discard
|
||||||
|
@ -60,7 +60,8 @@ 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)
|
|
||||||
|
newHEADRef := GetHEADRef(t, dir)
|
||||||
require.Equal(t, headRef, newHEADRef)
|
require.Equal(t, headRef, newHEADRef)
|
||||||
} else {
|
} else {
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
@ -178,10 +179,12 @@ func ParseJSONLines(data []byte) [][]byte {
|
||||||
return bytes.Split(bytes.TrimSpace(data), []byte("\n"))
|
return bytes.Split(bytes.TrimSpace(data), []byte("\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetHEADRef(t *testing.T) string {
|
func GetHEADRef(t *testing.T, path string) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
cmd := exec.Command("git", "show-ref", "HEAD")
|
cmd := exec.Command("git", "show-ref", "HEAD")
|
||||||
|
cmd.Dir = path
|
||||||
|
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue