diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-02-01 17:18:20 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-02-01 17:18:20 +0300 |
commit | ba1869fbc23e53d2ea5ff87fa0501097cf532107 (patch) | |
tree | 42b92186dbe071cd62b6244f548c0274a571e5dd | |
parent | 450c53c7466468d0d1922d47f1dc5c27168d6e74 (diff) |
fetch: Demonstrate that we're writing FETCH_HEAD
Extend tests which use git-fetch(1) to demonstrate that we're writing
the FETCH_HEAD file.
-rw-r--r-- | internal/git/localrepo/remote_extra_test.go | 2 | ||||
-rw-r--r-- | internal/git/localrepo/remote_test.go | 4 | ||||
-rw-r--r-- | internal/git/objectpool/fetch_test.go | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/internal/git/localrepo/remote_extra_test.go b/internal/git/localrepo/remote_extra_test.go index 5c40c9290..eb834325b 100644 --- a/internal/git/localrepo/remote_extra_test.go +++ b/internal/git/localrepo/remote_extra_test.go @@ -79,6 +79,8 @@ func TestRepo_FetchInternal(t *testing.T) { // Assert that we're using the expected Git protocol version, which is protocol v2. require.Equal(t, "GIT_PROTOCOL=version=2\n", readGitProtocol()) + + require.FileExists(t, filepath.Join(repoPath, "FETCH_HEAD")) }) t.Run("refspec without tags", func(t *testing.T) { diff --git a/internal/git/localrepo/remote_test.go b/internal/git/localrepo/remote_test.go index 3a0eb19b0..ed83b8e3b 100644 --- a/internal/git/localrepo/remote_test.go +++ b/internal/git/localrepo/remote_test.go @@ -63,7 +63,7 @@ func TestRepo_FetchRemote(t *testing.T) { }) t.Run("ok", func(t *testing.T) { - repo, _ := initBareWithRemote(t, "origin") + repo, repoPath := initBareWithRemote(t, "origin") var stderr bytes.Buffer require.NoError(t, repo.FetchRemote(ctx, "origin", FetchOpts{Stderr: &stderr})) @@ -78,6 +78,8 @@ func TestRepo_FetchRemote(t *testing.T) { sha, err := repo.ResolveRevision(ctx, git.Revision("refs/remotes/origin/master^{commit}")) require.NoError(t, err, "the object from remote should exists in local after fetch done") require.Equal(t, git.ObjectID("1e292f8fedd741b75372e19097c76d327140c312"), sha) + + require.FileExists(t, filepath.Join(repoPath, "FETCH_HEAD")) }) t.Run("with env", func(t *testing.T) { diff --git a/internal/git/objectpool/fetch_test.go b/internal/git/objectpool/fetch_test.go index d650be1da..eedf1513e 100644 --- a/internal/git/objectpool/fetch_test.go +++ b/internal/git/objectpool/fetch_test.go @@ -226,6 +226,8 @@ func TestFetchFromOrigin_refs(t *testing.T) { }, strings.Split(text.ChompBytes(gittest.Exec(t, cfg, "-C", poolPath, "for-each-ref", "--format=%(refname)")), "\n"), ) + + require.FileExists(t, filepath.Join(poolPath, "FETCH_HEAD")) } func resolveRef(t *testing.T, cfg config.Cfg, repo string, ref string) string { |