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

Function TestProjectsV1Deprecation

pkg/cmd/issue/edit/edit_test.go:2203–2280  ·  view source on GitHub ↗

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

2201// TODO projectsV1Deprecation
2202// Remove this test.
2203func TestProjectsV1Deprecation(t *testing.T) {
2204 t.Run("when projects v1 is supported, is included in query", func(t *testing.T) {
2205 ios, _, _, _ := iostreams.Test()
2206
2207 reg := &httpmock.Registry{}
2208 reg.Register(
2209 httpmock.GraphQL(`projectCards`),
2210 // Simulate a GraphQL error to early exit the test.
2211 httpmock.StatusStringResponse(500, ""),
2212 )
2213
2214 _, cmdTeardown := run.Stub()
2215 defer cmdTeardown(t)
2216
2217 // Ignore the error because we have no way to really stub it without
2218 // fully stubbing a GQL error structure in the request body.
2219 _ = editRun(&EditOptions{
2220 IO: ios,
2221 HttpClient: func() (*http.Client, error) {
2222 return &http.Client{Transport: reg}, nil
2223 },
2224 BaseRepo: func() (ghrepo.Interface, error) {
2225 return ghrepo.New("OWNER", "REPO"), nil
2226 },
2227 Detector: &fd.EnabledDetectorMock{},
2228
2229 IssueNumbers: []int{123},
2230 Projects: prShared.EditableProjects{
2231 EditableSlice: prShared.EditableSlice{
2232 Add: []string{"Test Project"},
2233 Edited: true,
2234 },
2235 },
2236 })
2237
2238 // Verify that our request contained projectCards
2239 reg.Verify(t)
2240 })
2241
2242 t.Run("when projects v1 is not supported, is not included in query", func(t *testing.T) {
2243 ios, _, _, _ := iostreams.Test()
2244
2245 reg := &httpmock.Registry{}
2246 reg.Exclude(t, httpmock.GraphQL(`projectCards`))
2247
2248 reg.Register(
2249 httpmock.GraphQL(`.*`),
2250 // Simulate a GraphQL error to early exit the test.
2251 httpmock.StatusStringResponse(500, ""),
2252 )
2253
2254 _, cmdTeardown := run.Stub()
2255 defer cmdTeardown(t)
2256
2257 // Ignore the error because we're not really interested in it.
2258 _ = editRun(&EditOptions{
2259 IO: ios,
2260 HttpClient: func() (*http.Client, error) {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected