MCPcopy
hub / github.com/cli/cli / TestSpecificPRResolver

Function TestSpecificPRResolver

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

Source from the content-addressed store, hash-verified

363}
364
365func TestSpecificPRResolver(t *testing.T) {
366 t.Run("when the PR Finder returns results, those are returned", func(t *testing.T) {
367 t.Parallel()
368
369 baseRepo, pr := stubPR("OWNER/REPO:master", "OWNER/REPO:feature")
370 mockFinder := shared.NewMockFinder("123", pr, baseRepo)
371 mockFinder.ExpectFields([]string{"number", "headRefName", "headRepository", "headRepositoryOwner", "isCrossRepository", "maintainerCanModify"})
372
373 resolver := &specificPRResolver{
374 prFinder: mockFinder,
375 selector: "123",
376 }
377
378 resolvedPR, resolvedBaseRepo, err := resolver.Resolve()
379 require.NoError(t, err)
380 require.Equal(t, pr, resolvedPR)
381 require.True(t, ghrepo.IsSame(baseRepo, resolvedBaseRepo), "expected repos to be the same")
382 })
383
384 t.Run("when the PR Finder errors, that error is returned", func(t *testing.T) {
385 t.Parallel()
386
387 mockFinder := shared.NewMockFinder("123", nil, nil)
388
389 resolver := &specificPRResolver{
390 prFinder: mockFinder,
391 selector: "123",
392 }
393
394 _, _, err := resolver.Resolve()
395 var notFoundErr *shared.NotFoundError
396 require.ErrorAs(t, err, &notFoundErr)
397 })
398}
399
400func TestPromptingPRResolver(t *testing.T) {
401 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