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

Function TestProjectsV1Deprecation

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

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

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