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

Function TestNewCmdEdit

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

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
PathMethod · 0.65
BaseRepoMethod · 0.65

Tested by

no test coverage detected