MCPcopy
hub / github.com/cli/cli / TestNewCmdEdit

Function TestNewCmdEdit

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

Source from the content-addressed store, hash-verified

26)
27
28func TestNewCmdEdit(t *testing.T) {
29 tmpFile := filepath.Join(t.TempDir(), "my-body.md")
30 err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
31 require.NoError(t, err)
32
33 tests := []struct {
34 name string
35 input string
36 stdin string
37 output EditOptions
38 expectedBaseRepo ghrepo.Interface
39 wantsErr bool
40 }{
41 {
42 name: "no argument",
43 input: "",
44 output: EditOptions{},
45 wantsErr: true,
46 },
47 {
48 name: "issue number argument",
49 input: "23",
50 output: EditOptions{
51 IssueNumbers: []int{23},
52 Interactive: true,
53 },
54 wantsErr: false,
55 },
56 {
57 name: "title flag",
58 input: "23 --title test",
59 output: EditOptions{
60 IssueNumbers: []int{23},
61 Editable: prShared.Editable{
62 Title: prShared.EditableString{
63 Value: "test",
64 Edited: true,
65 },
66 },
67 },
68 wantsErr: false,
69 },
70 {
71 name: "body flag",
72 input: "23 --body test",
73 output: EditOptions{
74 IssueNumbers: []int{23},
75 Editable: prShared.Editable{
76 Body: prShared.EditableString{
77 Value: "test",
78 Edited: true,
79 },
80 },
81 },
82 wantsErr: false,
83 },
84 {
85 name: "body from stdin",

Callers

nothing calls this directly

Calls 12

NewWithHostFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
JoinMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
NewCmdEditFunction · 0.70
RunMethod · 0.65
BaseRepoMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected