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

Function TestProjectsV1Deprecation

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

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

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