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

Function Test_editRun

pkg/cmd/release/edit/edit_test.go:208–475  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

206}
207
208func Test_editRun(t *testing.T) {
209 tests := []struct {
210 name string
211 isTTY bool
212 opts EditOptions
213 httpStubs func(t *testing.T, reg *httpmock.Registry)
214 wantErr string
215 wantStdout string
216 wantStderr string
217 }{
218 {
219 name: "edit the tag name",
220 isTTY: true,
221 opts: EditOptions{
222 TagName: "v1.2.4",
223 },
224 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
225 mockSuccessfulEditResponse(reg, func(params map[string]interface{}) {
226 assert.Equal(t, map[string]interface{}{
227 "tag_name": "v1.2.4",
228 }, params)
229 })
230 },
231 wantStdout: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n",
232 wantStderr: "",
233 },
234 {
235 name: "edit the target",
236 isTTY: true,
237 opts: EditOptions{
238 Target: "c0ff33",
239 },
240 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
241 mockSuccessfulEditResponse(reg, func(params map[string]interface{}) {
242 assert.Equal(t, map[string]interface{}{
243 "tag_name": "v1.2.3",
244 "target_commitish": "c0ff33",
245 }, params)
246 })
247 },
248 wantStdout: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n",
249 wantStderr: "",
250 },
251 {
252 name: "edit the release name",
253 isTTY: true,
254 opts: EditOptions{
255 Name: stringPtr("Hot Release #1"),
256 },
257 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
258 mockSuccessfulEditResponse(reg, func(params map[string]interface{}) {
259 assert.Equal(t, map[string]interface{}{
260 "tag_name": "v1.2.3",
261 "name": "Hot Release #1",
262 }, params)
263 })
264 },
265 wantStdout: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n",

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
TestFunction · 0.92
StubFetchReleaseFunction · 0.92
FromFullNameFunction · 0.92
stringPtrFunction · 0.85
EqualMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80

Tested by

no test coverage detected