MCPcopy
hub / github.com/cli/cli / TestProjectsV1Deprecation

Function TestProjectsV1Deprecation

pkg/cmd/pr/create/create_test.go:2633–3065  ·  view source on GitHub ↗

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

2631// TODO projectsV1Deprecation
2632// Remove this test.
2633func TestProjectsV1Deprecation(t *testing.T) {
2634
2635 t.Run("non-interactive submission", func(t *testing.T) {
2636 t.Run("when projects v1 is supported, queries for it", func(t *testing.T) {
2637 ios, _, _, _ := iostreams.Test()
2638
2639 reg := &httpmock.Registry{}
2640 reg.StubRepoInfoResponse("OWNER", "REPO", "main")
2641 reg.Register(
2642 // ( is required to avoid matching projectsV2
2643 httpmock.GraphQL(`projects\(`),
2644 // Simulate a GraphQL error to early exit the test.
2645 httpmock.StatusStringResponse(500, ""),
2646 )
2647
2648 cs, cmdTeardown := run.Stub()
2649 defer cmdTeardown(t)
2650
2651 cs.Register(`git config --get-regexp \^branch\\\..+\\\.\(remote\|merge\|pushremote\|gh-merge-base\)\$`, 0, "")
2652
2653 // Ignore the error because we have no way to really stub it without
2654 // fully stubbing a GQL error structure in the request body.
2655 _ = createRun(&CreateOptions{
2656 Detector: &fd.EnabledDetectorMock{},
2657 IO: ios,
2658 HttpClient: func() (*http.Client, error) {
2659 return &http.Client{Transport: reg}, nil
2660 },
2661 GitClient: &git.Client{
2662 GhPath: "some/path/gh",
2663 GitPath: "some/path/git",
2664 },
2665 Remotes: func() (context.Remotes, error) {
2666 return context.Remotes{
2667 {
2668 Remote: &git.Remote{
2669 Name: "upstream",
2670 Resolved: "base",
2671 },
2672 Repo: ghrepo.New("OWNER", "REPO"),
2673 },
2674 }, nil
2675 },
2676 Finder: shared.NewMockFinder("feature", nil, nil),
2677
2678 HeadBranch: "feature",
2679
2680 TitleProvided: true,
2681 BodyProvided: true,
2682 Title: "Test Title",
2683 Body: "Test Body",
2684
2685 // Required to force a lookup of projects
2686 Projects: []string{"Project"},
2687 })
2688
2689 // Verify that our request contained projects
2690 reg.Verify(t)

Callers

nothing calls this directly

Calls 15

StubRepoInfoResponseMethod · 0.95
RegisterMethod · 0.95
VerifyMethod · 0.95
ExcludeMethod · 0.95
StubRepoResponseMethod · 0.95
TestFunction · 0.92
GraphQLFunction · 0.92
StatusStringResponseFunction · 0.92
StubFunction · 0.92
NewFunction · 0.92
NewMockFinderFunction · 0.92
StringResponseFunction · 0.92

Tested by

no test coverage detected