MCPcopy
hub / github.com/cli/cli / Test_NewCmdEdit

Function Test_NewCmdEdit

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

Source from the content-addressed store, hash-verified

19)
20
21func Test_NewCmdEdit(t *testing.T) {
22 tempDir := t.TempDir()
23 tf, err := os.CreateTemp(tempDir, "release-create")
24 require.NoError(t, err)
25 fmt.Fprint(tf, "MY NOTES")
26 tf.Close()
27
28 tests := []struct {
29 name string
30 args string
31 isTTY bool
32 stdin string
33 want EditOptions
34 wantErr string
35 }{
36 {
37 name: "no arguments notty",
38 args: "",
39 isTTY: false,
40 wantErr: "accepts 1 arg(s), received 0",
41 },
42 {
43 name: "provide title and notes",
44 args: "v1.2.3 --title 'Some Title' --notes 'Some Notes'",
45 isTTY: false,
46 want: EditOptions{
47 TagName: "",
48 Name: stringPtr("Some Title"),
49 Body: stringPtr("Some Notes"),
50 },
51 },
52 {
53 name: "provide discussion category",
54 args: "v1.2.3 --discussion-category some-category",
55 isTTY: false,
56 want: EditOptions{
57 TagName: "",
58 DiscussionCategory: stringPtr("some-category"),
59 },
60 },
61 {
62 name: "provide tag and target commitish",
63 args: "v1.2.3 --tag v9.8.7 --target 97ea5e77b4d61d5d80ed08f7512847dee3ec9af5",
64 isTTY: false,
65 want: EditOptions{
66 TagName: "v9.8.7",
67 Target: "97ea5e77b4d61d5d80ed08f7512847dee3ec9af5",
68 },
69 },
70 {
71 name: "provide prerelease",
72 args: "v1.2.3 --prerelease",
73 isTTY: false,
74 want: EditOptions{
75 TagName: "",
76 Prerelease: boolPtr(true),
77 },
78 },

Callers

nothing calls this directly

Calls 11

TestFunction · 0.92
stringPtrFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
boolPtrFunction · 0.70
NewCmdEditFunction · 0.70
CloseMethod · 0.65
NameMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected