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

Function TestSpecificPRResolver

pkg/cmd/pr/checkout/checkout_test.go:758–791  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

756}
757
758func TestSpecificPRResolver(t *testing.T) {
759 t.Run("when the PR Finder returns results, those are returned", func(t *testing.T) {
760 t.Parallel()
761
762 baseRepo, pr := stubPR("OWNER/REPO:master", "OWNER/REPO:feature")
763 mockFinder := shared.NewMockFinder("123", pr, baseRepo)
764 mockFinder.ExpectFields([]string{"number", "headRefName", "headRepository", "headRepositoryOwner", "isCrossRepository", "maintainerCanModify"})
765
766 resolver := &specificPRResolver{
767 prFinder: mockFinder,
768 selector: "123",
769 }
770
771 resolvedPR, resolvedBaseRepo, err := resolver.Resolve()
772 require.NoError(t, err)
773 require.Equal(t, pr, resolvedPR)
774 require.True(t, ghrepo.IsSame(baseRepo, resolvedBaseRepo), "expected repos to be the same")
775 })
776
777 t.Run("when the PR Finder errors, that error is returned", func(t *testing.T) {
778 t.Parallel()
779
780 mockFinder := shared.NewMockFinder("123", nil, nil)
781
782 resolver := &specificPRResolver{
783 prFinder: mockFinder,
784 selector: "123",
785 }
786
787 _, _, err := resolver.Resolve()
788 var notFoundErr *shared.NotFoundError
789 require.ErrorAs(t, err, &notFoundErr)
790 })
791}
792
793func TestPromptingPRResolver(t *testing.T) {
794 t.Run("when the PR Lister has results, then we prompt for a choice", func(t *testing.T) {

Callers

nothing calls this directly

Calls 7

ResolveMethod · 0.95
NewMockFinderFunction · 0.92
IsSameFunction · 0.92
EqualMethod · 0.80
stubPRFunction · 0.70
RunMethod · 0.65
ExpectFieldsMethod · 0.45

Tested by

no test coverage detected