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

Function TestProjectsV1Deprecation

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

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

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