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

Function TestProjectsV1Deprecation

pkg/cmd/issue/create/create_test.go:2059–2198  ·  view source on GitHub ↗

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

2057// TODO projectsV1Deprecation
2058// Remove this test.
2059func TestProjectsV1Deprecation(t *testing.T) {
2060
2061 t.Run("non-interactive submission", func(t *testing.T) {
2062 t.Run("when projects v1 is supported, queries for it", func(t *testing.T) {
2063 ios, _, _, _ := iostreams.Test()
2064
2065 reg := &httpmock.Registry{}
2066 reg.StubIssueRepoInfoResponse("OWNER", "REPO")
2067 reg.Register(
2068 // ( is required to avoid matching projectsV2
2069 httpmock.GraphQL(`projects\(`),
2070 // Simulate a GraphQL error to early exit the test.
2071 httpmock.StatusStringResponse(500, ""),
2072 )
2073
2074 _, cmdTeardown := run.Stub()
2075 defer cmdTeardown(t)
2076
2077 // Ignore the error because we have no way to really stub it without
2078 // fully stubbing a GQL error structure in the request body.
2079 _ = createRun(&CreateOptions{
2080 IO: ios,
2081 HttpClient: func() (*http.Client, error) {
2082 return &http.Client{Transport: reg}, nil
2083 },
2084 BaseRepo: func() (ghrepo.Interface, error) {
2085 return ghrepo.New("OWNER", "REPO"), nil
2086 },
2087
2088 Detector: &fd.EnabledDetectorMock{},
2089 Title: "Test Title",
2090 Body: "Test Body",
2091 // Required to force a lookup of projects
2092 Projects: []string{"Project"},
2093 })
2094
2095 // Verify that our request contained projects
2096 reg.Verify(t)
2097 })
2098
2099 t.Run("when projects v1 is not supported, does not query for it", func(t *testing.T) {
2100 ios, _, _, _ := iostreams.Test()
2101
2102 reg := &httpmock.Registry{}
2103 reg.StubIssueRepoInfoResponse("OWNER", "REPO")
2104 // ( is required to avoid matching projectsV2
2105 reg.Exclude(t, httpmock.GraphQL(`projects\(`))
2106
2107 _, cmdTeardown := run.Stub()
2108 defer cmdTeardown(t)
2109
2110 // Ignore the error because we're not really interested in it.
2111 _ = createRun(&CreateOptions{
2112 IO: ios,
2113 HttpClient: func() (*http.Client, error) {
2114 return &http.Client{Transport: reg}, nil
2115 },
2116 BaseRepo: func() (ghrepo.Interface, error) {

Callers

nothing calls this directly

Calls 11

RegisterMethod · 0.95
VerifyMethod · 0.95
ExcludeMethod · 0.95
TestFunction · 0.92
GraphQLFunction · 0.92
StatusStringResponseFunction · 0.92
StubFunction · 0.92
NewFunction · 0.92
createRunFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected