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

Function TestProjectsV1Deprecation

pkg/cmd/pr/edit/edit_test.go:1958–2024  ·  view source on GitHub ↗

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

1956// TODO projectsV1Deprecation
1957// Remove this test.
1958func TestProjectsV1Deprecation(t *testing.T) {
1959 t.Run("when projects v1 is supported, is included in query", func(t *testing.T) {
1960 ios, _, _, _ := iostreams.Test()
1961
1962 reg := &httpmock.Registry{}
1963 reg.Register(
1964 httpmock.GraphQL(`projectCards`),
1965 // Simulate a GraphQL error to early exit the test.
1966 httpmock.StatusStringResponse(500, ""),
1967 )
1968
1969 f := &cmdutil.Factory{
1970 IOStreams: ios,
1971 HttpClient: func() (*http.Client, error) {
1972 return &http.Client{Transport: reg}, nil
1973 },
1974 }
1975
1976 // Ignore the error because we have no way to really stub it without
1977 // fully stubbing a GQL error structure in the request body.
1978 _ = editRun(&EditOptions{
1979 IO: ios,
1980 HttpClient: func() (*http.Client, error) {
1981 return &http.Client{Transport: reg}, nil
1982 },
1983 Detector: &fd.EnabledDetectorMock{},
1984
1985 Finder: shared.NewFinder(f),
1986
1987 SelectorArg: "https://github.com/cli/cli/pull/123",
1988 })
1989
1990 // Verify that our request contained projectCards
1991 reg.Verify(t)
1992 })
1993
1994 t.Run("when projects v1 is not supported, is not included in query", func(t *testing.T) {
1995 ios, _, _, _ := iostreams.Test()
1996
1997 reg := &httpmock.Registry{}
1998 reg.Exclude(t, httpmock.GraphQL(`projectCards`))
1999
2000 f := &cmdutil.Factory{
2001 IOStreams: ios,
2002 HttpClient: func() (*http.Client, error) {
2003 return &http.Client{Transport: reg}, nil
2004 },
2005 }
2006
2007 // Ignore the error because we have no way to really stub it without
2008 // fully stubbing a GQL error structure in the request body.
2009 _ = editRun(&EditOptions{
2010 IO: ios,
2011 HttpClient: func() (*http.Client, error) {
2012 return &http.Client{Transport: reg}, nil
2013 },
2014 Detector: &fd.DisabledDetectorMock{},
2015

Callers

nothing calls this directly

Calls 9

RegisterMethod · 0.95
VerifyMethod · 0.95
ExcludeMethod · 0.95
TestFunction · 0.92
GraphQLFunction · 0.92
StatusStringResponseFunction · 0.92
NewFinderFunction · 0.92
editRunFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected