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

Function TestNewCmdEdit

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

NewWithHostFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
JoinMethod · 0.80
WriteFileMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
EventsMethod · 0.80
NewCmdEditFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected