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

Function Test_NewCmdEdit

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected