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

Function TestNewCmdCreate

pkg/cmd/issue/create/create_test.go:36–388  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func TestNewCmdCreate(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 attachmentEvent := []ghtelemetry.Event{{
45 Type: "attachment_invocation",
46 Dimensions: ghtelemetry.Dimensions{"command": "create"},
47 Measures: ghtelemetry.Measures{
48 "attach_count": 1, "append_ops_count": 0, "replace_ops_count": 0,
49 },
50 }}
51
52 tests := []struct {
53 name string
54 tty bool
55 stdin string
56 cli string
57 config 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 wantsOpts CreateOptions
64 wantAssetPaths []string
65 wantEvents []ghtelemetry.Event
66 wantSampleRate int
67 }{
68 {
69 name: "empty non-tty",
70 tty: false,
71 cli: "",
72 wantsErr: true,
73 },
74 {
75 name: "only title non-tty",
76 tty: false,
77 cli: "-t mytitle",
78 wantsErr: true,
79 },
80 {
81 name: "empty tty",
82 tty: true,
83 cli: "",
84 wantsErr: false,
85 wantsOpts: CreateOptions{
86 Title: "",
87 Body: "",
88 RecoverFile: "",
89 WebMode: false,
90 Interactive: true,
91 },
92 },
93 {

Callers

nothing calls this directly

Calls 14

TestFunction · 0.92
NewMockConfigFromStringFunction · 0.92
NewMockConfigFunction · 0.92
JoinMethod · 0.80
WriteFileMethod · 0.80
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
EventsMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected