MCPcopy
hub / github.com/cli/cli / Test_listRun

Function Test_listRun

pkg/cmd/release/list/list_test.go:119–389  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

117}
118
119func Test_listRun(t *testing.T) {
120 oneDayAgo := time.Now().Add(time.Duration(-24) * time.Hour)
121
122 frozenTime, err := time.Parse(time.RFC3339, "2020-08-31T15:44:24+02:00")
123 require.NoError(t, err)
124
125 httpStubs := func(createdAt time.Time) func(t *testing.T, reg *httpmock.Registry) {
126 return func(t *testing.T, reg *httpmock.Registry) {
127 reg.Register(
128 httpmock.GraphQL(`\bRepositoryReleaseList\(`),
129 httpmock.GraphQLQuery(
130 fmt.Sprintf(`
131 { "data": { "repository": { "releases": {
132 "nodes": [
133 {
134 "name": "",
135 "tagName": "v1.1.0",
136 "isLatest": false,
137 "isDraft": true,
138 "isPrerelease": false,
139 "immutable": false,
140 "createdAt": "%[1]s",
141 "publishedAt": "%[1]s"
142 },
143 {
144 "name": "The big 1.0",
145 "tagName": "v1.0.0",
146 "isLatest": true,
147 "isDraft": false,
148 "isPrerelease": false,
149 "immutable": false,
150 "createdAt": "%[1]s",
151 "publishedAt": "%[1]s"
152 },
153 {
154 "name": "1.0 release candidate",
155 "tagName": "v1.0.0-pre.2",
156 "isLatest": false,
157 "isDraft": false,
158 "isPrerelease": true,
159 "immutable": true,
160 "createdAt": "%[1]s",
161 "publishedAt": "%[1]s"
162 },
163 {
164 "name": "New features",
165 "tagName": "v0.9.2",
166 "isLatest": false,
167 "isDraft": false,
168 "isPrerelease": false,
169 "immutable": true,
170 "createdAt": "%[1]s",
171 "publishedAt": "%[1]s"
172 }
173 ]
174 } } } }`, createdAt.Format(time.RFC3339)),
175 func(s string, m map[string]interface{}) {
176 // Assert "immutable" field is requested

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
GraphQLFunction · 0.92
GraphQLQueryFunction · 0.92
TestFunction · 0.92
FromFullNameFunction · 0.92
NewJSONExporterFunction · 0.92
DurationMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
SetFieldsMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected