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

Function TestSpecificPRResolver

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

Source from the content-addressed store, hash-verified

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