MCPcopy
hub / github.com/cli/cli / TestProjectsV1Deprecation

Function TestProjectsV1Deprecation

pkg/cmd/issue/view/view_test.go:539–598  ·  view source on GitHub ↗

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

537// TODO projectsV1Deprecation
538// Remove this test.
539func TestProjectsV1Deprecation(t *testing.T) {
540 t.Run("when projects v1 is supported, is included in query", func(t *testing.T) {
541 ios, _, _, _ := iostreams.Test()
542
543 reg := &httpmock.Registry{}
544 reg.Register(
545 httpmock.GraphQL(`projectCards`),
546 // Simulate a GraphQL error to early exit the test.
547 httpmock.StatusStringResponse(500, ""),
548 )
549
550 _, cmdTeardown := run.Stub()
551 defer cmdTeardown(t)
552
553 // Ignore the error because we have no way to really stub it without
554 // fully stubbing a GQL error structure in the request body.
555 _ = viewRun(&ViewOptions{
556 IO: ios,
557 HttpClient: func() (*http.Client, error) {
558 return &http.Client{Transport: reg}, nil
559 },
560 BaseRepo: func() (ghrepo.Interface, error) {
561 return ghrepo.New("OWNER", "REPO"), nil
562 },
563
564 Detector: &fd.EnabledDetectorMock{},
565 IssueNumber: 123,
566 })
567
568 // Verify that our request contained projectCards
569 reg.Verify(t)
570 })
571
572 t.Run("when projects v1 is not supported, is not included in query", func(t *testing.T) {
573 ios, _, _, _ := iostreams.Test()
574
575 reg := &httpmock.Registry{}
576 reg.Exclude(t, httpmock.GraphQL(`projectCards`))
577
578 _, cmdTeardown := run.Stub()
579 defer cmdTeardown(t)
580
581 // Ignore the error because we're not really interested in it.
582 _ = viewRun(&ViewOptions{
583 IO: ios,
584 HttpClient: func() (*http.Client, error) {
585 return &http.Client{Transport: reg}, nil
586 },
587 BaseRepo: func() (ghrepo.Interface, error) {
588 return ghrepo.New("OWNER", "REPO"), nil
589 },
590
591 Detector: &fd.DisabledDetectorMock{},
592 IssueNumber: 123,
593 })
594
595 // Verify that our request contained projectCards
596 reg.Verify(t)

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
viewRunFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected