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

Function TestClientShowRefsSeparatesRefsFromOptions

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

Source from the content-addressed store, hash-verified

302}
303
304func TestClientShowRefsSeparatesRefsFromOptions(t *testing.T) {
305 // Given a repository with one branch
306 repo := newTestRepo(t)
307 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "initial commit")
308 wantHash := repo.run(t, "rev-parse", "HEAD")
309
310 // When the branch and an option-like ref are resolved
311 refs, err := repo.client.ShowRefs(t.Context(), []string{"refs/heads/trunk", "--quiet"})
312
313 // Then an option separator protects the refs, so the branch resolves and the option-like ref is rejected
314 require.Error(t, err)
315 var gitError *GitError
316 require.ErrorAs(t, err, &gitError)
317 assert.NotZero(t, gitError.ExitCode)
318 assert.Equal(t, []Ref{{Hash: wantHash, Name: "refs/heads/trunk"}}, refs)
319}
320
321func TestClientConfigReturnsConfiguredValue(t *testing.T) {
322 // Given a repository with a configured credential helper

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