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

Function TestNewCmdCreate

pkg/cmd/issue/create/create_test.go:36–375  ·  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 tests := []struct {
45 name string
46 tty bool
47 stdin string
48 cli string
49 config string
50 wantsErr bool
51 wantsErrMsg string
52 // wantErrIsNotExist covers an error whose text the operating system
53 // words differently, so the assertion cannot be on the message.
54 wantErrIsNotExist bool
55 wantsOpts CreateOptions
56 wantAssetPaths []string
57 }{
58 {
59 name: "empty non-tty",
60 tty: false,
61 cli: "",
62 wantsErr: true,
63 },
64 {
65 name: "only title non-tty",
66 tty: false,
67 cli: "-t mytitle",
68 wantsErr: true,
69 },
70 {
71 name: "empty tty",
72 tty: true,
73 cli: "",
74 wantsErr: false,
75 wantsOpts: CreateOptions{
76 Title: "",
77 Body: "",
78 RecoverFile: "",
79 WebMode: false,
80 Interactive: true,
81 },
82 },
83 {
84 name: "body from stdin",
85 tty: false,
86 stdin: "this is on standard input",
87 cli: "-t mytitle -F -",
88 wantsErr: false,
89 wantsOpts: CreateOptions{
90 Title: "mytitle",
91 Body: "this is on standard input",
92 RecoverFile: "",
93 WebMode: false,

Callers

nothing calls this directly

Calls 15

TestFunction · 0.92
NewMockConfigFromStringFunction · 0.92
NewMockConfigFunction · 0.92
JoinMethod · 0.80
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
ChangedMethod · 0.80
EqualMethod · 0.80
EmptyMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected