MCPcopy
hub / github.com/cli/cli / Test_createRun

Function Test_createRun

pkg/cmd/release/create/create_test.go:431–1305  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

429}
430
431func Test_createRun(t *testing.T) {
432 const contentCmd = `git tag --list .* --format=%\(contents\)`
433 const signatureCmd = `git tag --list .* --format=%\(contents:signature\)`
434
435 defaultRunStubs := func(rs *run.CommandStubber) {
436 rs.Register(contentCmd, 0, "")
437 rs.Register(signatureCmd, 0, "")
438 }
439
440 tests := []struct {
441 name string
442 isTTY bool
443 opts CreateOptions
444 httpStubs func(t *testing.T, reg *httpmock.Registry)
445 runStubs func(rs *run.CommandStubber)
446 wantErr string
447 wantStdout string
448 wantStderr string
449 }{
450 {
451 name: "create a release",
452 isTTY: true,
453 opts: CreateOptions{
454 TagName: "v1.2.3",
455 Name: "The Big 1.2",
456 Body: "* Fixed bugs",
457 BodyProvided: true,
458 Target: "",
459 },
460 runStubs: defaultRunStubs,
461 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
462 reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases"), httpmock.RESTPayload(201, `{
463 "url": "https://api.github.com/releases/123",
464 "upload_url": "https://api.github.com/assets/upload",
465 "html_url": "https://github.com/OWNER/REPO/releases/tag/v1.2.3"
466 }`, func(params map[string]interface{}) {
467 assert.Equal(t, map[string]interface{}{
468 "tag_name": "v1.2.3",
469 "name": "The Big 1.2",
470 "body": "* Fixed bugs",
471 "draft": false,
472 "prerelease": false,
473 }, params)
474 }))
475 },
476 wantStdout: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n",
477 wantStderr: ``,
478 },
479 {
480 name: "create a release if there are new commits and the last release does not exist",
481 isTTY: true,
482 opts: CreateOptions{
483 TagName: "v1.2.3",
484 Name: "The Big 1.2",
485 Body: "* Fixed bugs",
486 BodyProvided: true,
487 Target: "",
488 FailOnNoCommits: true,

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
RESTFunction · 0.92
RESTPayloadFunction · 0.92
StatusStringResponseFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
StatusScopesResponderFunction · 0.92
TestFunction · 0.92
FromFullNameFunction · 0.92
StubFunction · 0.92
EqualMethod · 0.80
SetStdoutTTYMethod · 0.80

Tested by

no test coverage detected