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

Function TestProjectsV1Deprecation

pkg/cmd/issue/view/view_test.go:551–610  ·  view source on GitHub ↗

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

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