From 976cc9400795b8a6e04f24dc28df964898edd537 Mon Sep 17 00:00:00 2001 From: Arseny Balobanov Date: Wed, 3 Mar 2021 01:18:30 +0300 Subject: [PATCH] [gitfame] Test that HEAD is not modified. --- gitfame/test/integration/gitfame_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gitfame/test/integration/gitfame_test.go b/gitfame/test/integration/gitfame_test.go index e7e51a5..8047338 100644 --- a/gitfame/test/integration/gitfame_test.go +++ b/gitfame/test/integration/gitfame_test.go @@ -51,6 +51,7 @@ func TestGitFame(t *testing.T) { args = append(args, tc.Args...) Unbundle(t, filepath.Join(bundlesDir, tc.Bundle), dir) + headRef := GetHEADRef(t) cmd := exec.Command(binary, args...) cmd.Stderr = ioutil.Discard @@ -59,6 +60,8 @@ func TestGitFame(t *testing.T) { if !tc.Error { require.NoError(t, err) CompareResults(t, tc.Expected, output, tc.Format) + newHEADRef := GetHEADRef(t) + require.Equal(t, headRef, newHEADRef) } else { require.Error(t, err) _, ok := err.(*exec.ExitError) @@ -174,3 +177,13 @@ func CompareJSONLines(t *testing.T, expected, actual []byte) { func ParseJSONLines(data []byte) [][]byte { return bytes.Split(bytes.TrimSpace(data), []byte("\n")) } + +func GetHEADRef(t *testing.T) string { + t.Helper() + + cmd := exec.Command("git", "show-ref", "HEAD") + out, err := cmd.Output() + require.NoError(t, err) + + return string(out) +}