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

Function TestProjectsV1Deprecation

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

TODO projectsV1Deprecation Remove this test.

(t *testing.T)

Source from the content-addressed store, hash-verified

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

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