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

Function TestProjectsV1Deprecation

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

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

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