MCPcopy Index your code
hub / github.com/cli/cli / TestProjectsV1Deprecation

Function TestProjectsV1Deprecation

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

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

1614// TODO projectsV1Deprecation
1615// Remove this test.
1616func TestProjectsV1Deprecation(t *testing.T) {
1617 t.Run("when projects v1 is supported, is included in query", func(t *testing.T) {
1618 ios, _, _, _ := iostreams.Test()
1619
1620 reg := &httpmock.Registry{}
1621 reg.Register(
1622 httpmock.GraphQL(`projectCards`),
1623 // Simulate a GraphQL error to early exit the test.
1624 httpmock.StatusStringResponse(500, ""),
1625 )
1626
1627 _, cmdTeardown := run.Stub()
1628 defer cmdTeardown(t)
1629
1630 // Ignore the error because we have no way to really stub it without
1631 // fully stubbing a GQL error structure in the request body.
1632 _ = editRun(&EditOptions{
1633 IO: ios,
1634 HttpClient: func() (*http.Client, error) {
1635 return &http.Client{Transport: reg}, nil
1636 },
1637 BaseRepo: func() (ghrepo.Interface, error) {
1638 return ghrepo.New("OWNER", "REPO"), nil
1639 },
1640 Detector: &fd.EnabledDetectorMock{},
1641
1642 IssueNumbers: []int{123},
1643 Editable: prShared.Editable{
1644 Projects: prShared.EditableProjects{
1645 EditableSlice: prShared.EditableSlice{
1646 Add: []string{"Test Project"},
1647 Edited: true,
1648 },
1649 },
1650 },
1651 })
1652
1653 // Verify that our request contained projectCards
1654 reg.Verify(t)
1655 })
1656
1657 t.Run("when projects v1 is not supported, is not included in query", func(t *testing.T) {
1658 ios, _, _, _ := iostreams.Test()
1659
1660 reg := &httpmock.Registry{}
1661 reg.Exclude(t, httpmock.GraphQL(`projectCards`))
1662
1663 reg.Register(
1664 httpmock.GraphQL(`.*`),
1665 // Simulate a GraphQL error to early exit the test.
1666 httpmock.StatusStringResponse(500, ""),
1667 )
1668
1669 _, cmdTeardown := run.Stub()
1670 defer cmdTeardown(t)
1671
1672 // Ignore the error because we're not really interested in it.
1673 _ = editRun(&EditOptions{

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