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

Function TestClientCurrentBranchReportsDetachedHead

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

Source from the content-addressed store, hash-verified

270}
271
272func TestClientCurrentBranchReportsDetachedHead(t *testing.T) {
273 // Given a repository with a detached HEAD
274 repo := newTestRepo(t)
275 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "initial commit")
276 repo.run(t, "checkout", "--quiet", "--detach")
277
278 // When the current branch is requested
279 branch, err := repo.client.CurrentBranch(t.Context())
280
281 // Then the detached HEAD error is returned
282 require.Error(t, err)
283 assert.ErrorIs(t, err, ErrNotOnAnyBranch)
284 assert.Empty(t, branch)
285}
286
287func TestClientShowRefsReturnsExistingRefsAlongsideMissingRefError(t *testing.T) {
288 // Given a repository with one requested branch and one missing branch

Callers

nothing calls this directly

Calls 5

newTestRepoFunction · 0.85
EmptyMethod · 0.80
CurrentBranchMethod · 0.65
runMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected