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

Function TestNewCmdEdit

pkg/cmd/issue/edit/edit_test.go:36–528  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func TestNewCmdEdit(t *testing.T) {
37 tmpFile := filepath.Join(t.TempDir(), "my-body.md")
38 err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
39 require.NoError(t, err)
40
41 tmpImage := filepath.Join(t.TempDir(), "shot.png")
42 require.NoError(t, os.WriteFile(tmpImage, []byte("the bytes"), 0600))
43
44 tests := []struct {
45 name string
46 input string
47 stdin string
48 output EditOptions
49 expectedBaseRepo ghrepo.Interface
50 wantAssetPaths []string
51 wantsErr bool
52 wantsErrMsg string
53 // wantErrIsNotExist covers an error whose text the operating system
54 // words differently, so the assertion cannot be on the message.
55 wantErrIsNotExist bool
56 }{
57 {
58 name: "no argument",
59 input: "",
60 output: EditOptions{},
61 wantsErr: true,
62 },
63 {
64 name: "issue number argument",
65 input: "23",
66 output: EditOptions{
67 IssueNumbers: []int{23},
68 Interactive: true,
69 },
70 wantsErr: false,
71 },
72 {
73 name: "title flag",
74 input: "23 --title test",
75 output: EditOptions{
76 IssueNumbers: []int{23},
77 Editable: prShared.Editable{
78 Title: prShared.EditableString{
79 Value: "test",
80 Edited: true,
81 },
82 },
83 },
84 wantsErr: false,
85 },
86 {
87 name: "body flag",
88 input: "23 --body test",
89 output: EditOptions{
90 IssueNumbers: []int{23},
91 Editable: prShared.Editable{
92 Body: prShared.EditableString{
93 Value: "test",

Callers

nothing calls this directly

Calls 15

NewWithHostFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
JoinMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
ChangedMethod · 0.80
EqualMethod · 0.80
EmptyMethod · 0.80
NewCmdEditFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected