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

Function TestProjectsV1Deprecation

pkg/cmd/issue/create/create_test.go:2017–2156  ·  view source on GitHub ↗

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

2015// TODO projectsV1Deprecation
2016// Remove this test.
2017func TestProjectsV1Deprecation(t *testing.T) {
2018
2019 t.Run("non-interactive submission", func(t *testing.T) {
2020 t.Run("when projects v1 is supported, queries for it", func(t *testing.T) {
2021 ios, _, _, _ := iostreams.Test()
2022
2023 reg := &httpmock.Registry{}
2024 reg.StubIssueRepoInfoResponse("OWNER", "REPO")
2025 reg.Register(
2026 // ( is required to avoid matching projectsV2
2027 httpmock.GraphQL(`projects\(`),
2028 // Simulate a GraphQL error to early exit the test.
2029 httpmock.StatusStringResponse(500, ""),
2030 )
2031
2032 _, cmdTeardown := run.Stub()
2033 defer cmdTeardown(t)
2034
2035 // Ignore the error because we have no way to really stub it without
2036 // fully stubbing a GQL error structure in the request body.
2037 _ = createRun(&CreateOptions{
2038 IO: ios,
2039 HttpClient: func() (*http.Client, error) {
2040 return &http.Client{Transport: reg}, nil
2041 },
2042 BaseRepo: func() (ghrepo.Interface, error) {
2043 return ghrepo.New("OWNER", "REPO"), nil
2044 },
2045
2046 Detector: &fd.EnabledDetectorMock{},
2047 Title: "Test Title",
2048 Body: "Test Body",
2049 // Required to force a lookup of projects
2050 Projects: []string{"Project"},
2051 })
2052
2053 // Verify that our request contained projects
2054 reg.Verify(t)
2055 })
2056
2057 t.Run("when projects v1 is not supported, does not query for it", func(t *testing.T) {
2058 ios, _, _, _ := iostreams.Test()
2059
2060 reg := &httpmock.Registry{}
2061 reg.StubIssueRepoInfoResponse("OWNER", "REPO")
2062 // ( is required to avoid matching projectsV2
2063 reg.Exclude(t, httpmock.GraphQL(`projects\(`))
2064
2065 _, cmdTeardown := run.Stub()
2066 defer cmdTeardown(t)
2067
2068 // Ignore the error because we're not really interested in it.
2069 _ = createRun(&CreateOptions{
2070 IO: ios,
2071 HttpClient: func() (*http.Client, error) {
2072 return &http.Client{Transport: reg}, nil
2073 },
2074 BaseRepo: func() (ghrepo.Interface, error) {

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected