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

Function TestProjectsV1Deprecation

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

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

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