MCPcopy Index your code
hub / github.com/cli/cli / TestNewCmdCreate

Function TestNewCmdCreate

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

Source from the content-addressed store, hash-verified

30)
31
32func TestNewCmdCreate(t *testing.T) {
33 tmpFile := filepath.Join(t.TempDir(), "my-body.md")
34 err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
35 require.NoError(t, err)
36
37 tests := []struct {
38 name string
39 tty bool
40 stdin string
41 cli string
42 config string
43 wantsErr bool
44 wantsOpts CreateOptions
45 }{
46 {
47 name: "empty non-tty",
48 tty: false,
49 cli: "",
50 wantsErr: true,
51 },
52 {
53 name: "only title non-tty",
54 tty: false,
55 cli: "-t mytitle",
56 wantsErr: true,
57 },
58 {
59 name: "empty tty",
60 tty: true,
61 cli: "",
62 wantsErr: false,
63 wantsOpts: CreateOptions{
64 Title: "",
65 Body: "",
66 RecoverFile: "",
67 WebMode: false,
68 Interactive: true,
69 },
70 },
71 {
72 name: "body from stdin",
73 tty: false,
74 stdin: "this is on standard input",
75 cli: "-t mytitle -F -",
76 wantsErr: false,
77 wantsOpts: CreateOptions{
78 Title: "mytitle",
79 Body: "this is on standard input",
80 RecoverFile: "",
81 WebMode: false,
82 Interactive: false,
83 },
84 },
85 {
86 name: "body from file",
87 tty: false,
88 cli: fmt.Sprintf("-t mytitle -F '%s'", tmpFile),
89 wantsErr: false,

Callers

nothing calls this directly

Calls 11

TestFunction · 0.92
NewFromStringFunction · 0.92
NewBlankConfigFunction · 0.92
JoinMethod · 0.80
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected