MCPcopy Create free account
hub / github.com/cli/cli / TestClientShowRefsReturnsExistingRefsAlongsideMissingRefError

Function TestClientShowRefsReturnsExistingRefsAlongsideMissingRefError

git/client_test.go:287–302  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

285}
286
287func TestClientShowRefsReturnsExistingRefsAlongsideMissingRefError(t *testing.T) {
288 // Given a repository with one requested branch and one missing branch
289 repo := newTestRepo(t)
290 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "initial commit")
291 wantHash := repo.run(t, "rev-parse", "HEAD")
292
293 // When both refs are resolved
294 refs, err := repo.client.ShowRefs(t.Context(), []string{"refs/heads/trunk", "refs/heads/missing"})
295
296 // Then the existing ref and the semantic Git error are both returned
297 require.Error(t, err)
298 var gitError *GitError
299 require.ErrorAs(t, err, &gitError)
300 assert.NotZero(t, gitError.ExitCode)
301 assert.Equal(t, []Ref{{Hash: wantHash, Name: "refs/heads/trunk"}}, refs)
302}
303
304func TestClientShowRefsSeparatesRefsFromOptions(t *testing.T) {
305 // Given a repository with one branch

Callers

nothing calls this directly

Calls 5

newTestRepoFunction · 0.85
ShowRefsMethod · 0.80
EqualMethod · 0.80
runMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected