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

Function TestClientCommitsReturnsCommitMetadata

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

Source from the content-addressed store, hash-verified

391}
392
393func TestClientCommitsReturnsCommitMetadata(t *testing.T) {
394 // Given a branch with commits containing empty and multiline bodies
395 repo := newTestRepo(t)
396 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "base")
397 baseRef := repo.run(t, "rev-parse", "HEAD")
398 repo.run(t, "checkout", "--quiet", "-b", "feature")
399 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "first commit")
400 firstSHA := repo.run(t, "rev-parse", "HEAD")
401 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "second commit", "-m", "first line\nsecond line")
402 secondSHA := repo.run(t, "rev-parse", "HEAD")
403
404 // When commits unique to the feature branch are requested
405 commits, err := repo.client.Commits(t.Context(), baseRef, "feature")
406
407 // Then each commit's repository metadata is returned newest first
408 require.NoError(t, err)
409 assert.Equal(t, []*Commit{
410 {Sha: secondSHA, Title: "second commit", Body: "first line\nsecond line\n"},
411 {Sha: firstSHA, Title: "first commit"},
412 }, commits)
413}
414
415func TestClientCommitsReportsNoCommitsBetweenRefs(t *testing.T) {
416 // Given two refs that identify the same commit

Callers

nothing calls this directly

Calls 4

newTestRepoFunction · 0.85
EqualMethod · 0.80
CommitsMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected