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