MCPcopy
hub / github.com/cli/cli / Test_editRun

Function Test_editRun

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

Source from the content-addressed store, hash-verified

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