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

Function TestProjectsV1Deprecation

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

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

3075// TODO projectsV1Deprecation
3076// Remove this test.
3077func TestProjectsV1Deprecation(t *testing.T) {
3078
3079 t.Run("non-interactive submission", func(t *testing.T) {
3080 t.Run("when projects v1 is supported, queries for it", func(t *testing.T) {
3081 ios, _, _, _ := iostreams.Test()
3082
3083 reg := &httpmock.Registry{}
3084 reg.StubRepoInfoResponse("OWNER", "REPO", "main")
3085 reg.Register(
3086 // ( is required to avoid matching projectsV2
3087 httpmock.GraphQL(`projects\(`),
3088 // Simulate a GraphQL error to early exit the test.
3089 httpmock.StatusStringResponse(500, ""),
3090 )
3091
3092 cs, cmdTeardown := run.Stub()
3093 defer cmdTeardown(t)
3094
3095 cs.Register(`git config --get-regexp \^branch\\\..+\\\.\(remote\|merge\|pushremote\|gh-merge-base\)\$`, 0, "")
3096
3097 // Ignore the error because we have no way to really stub it without
3098 // fully stubbing a GQL error structure in the request body.
3099 _ = createRun(&CreateOptions{
3100 Detector: &fd.EnabledDetectorMock{},
3101 IO: ios,
3102 HttpClient: func() (*http.Client, error) {
3103 return &http.Client{Transport: reg}, nil
3104 },
3105 GitClient: &git.Client{
3106 GhPath: "some/path/gh",
3107 GitPath: "some/path/git",
3108 },
3109 Remotes: func() (context.Remotes, error) {
3110 return context.Remotes{
3111 {
3112 Remote: &git.Remote{
3113 Name: "upstream",
3114 Resolved: "base",
3115 },
3116 Repo: ghrepo.New("OWNER", "REPO"),
3117 },
3118 }, nil
3119 },
3120 Finder: shared.NewMockFinder("feature", nil, nil),
3121
3122 HeadBranch: "feature",
3123
3124 TitleProvided: true,
3125 BodyProvided: true,
3126 Title: "Test Title",
3127 Body: "Test Body",
3128
3129 // Required to force a lookup of projects
3130 Projects: []string{"Project"},
3131 })
3132
3133 // Verify that our request contained projects
3134 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