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

Function TestClientDeleteLocalBranchReportsCheckedOutBranch

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

Source from the content-addressed store, hash-verified

962}
963
964func TestClientDeleteLocalBranchReportsCheckedOutBranch(t *testing.T) {
965 // Given a repository whose trunk branch is checked out
966 repo := newTestRepo(t)
967 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "initial commit")
968
969 // When the checked out branch is deleted
970 err := repo.client.DeleteLocalBranch(t.Context(), "trunk")
971
972 // Then Git rejects the deletion and the branch remains
973 require.Error(t, err)
974 var gitError *GitError
975 require.ErrorAs(t, err, &gitError)
976 assert.NotZero(t, gitError.ExitCode)
977 assert.True(t, repo.client.HasLocalBranch(t.Context(), "trunk"), "checked out branch should remain")
978}
979
980func TestClientHasLocalBranchFindsExistingBranch(t *testing.T) {
981 // Given a repository with a trunk commit

Callers

nothing calls this directly

Calls 5

newTestRepoFunction · 0.85
DeleteLocalBranchMethod · 0.80
HasLocalBranchMethod · 0.65
runMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected