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

Function TestNewCmdCreate

pkg/cmd/gist/create/create_test.go:57–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestNewCmdCreate(t *testing.T) {
58 tests := []struct {
59 name string
60 cli string
61 factory func(*cmdutil.Factory) *cmdutil.Factory
62 wants CreateOptions
63 wantsErr bool
64 }{
65 {
66 name: "no arguments",
67 cli: "",
68 wants: CreateOptions{
69 Description: "",
70 Public: false,
71 Filenames: []string{""},
72 },
73 wantsErr: false,
74 },
75 {
76 name: "no arguments with TTY stdin",
77 factory: func(f *cmdutil.Factory) *cmdutil.Factory {
78 f.IOStreams.SetStdinTTY(true)
79 return f
80 },
81 cli: "",
82 wants: CreateOptions{
83 Description: "",
84 Public: false,
85 Filenames: []string{""},
86 },
87 wantsErr: true,
88 },
89 {
90 name: "stdin argument",
91 cli: "-",
92 wants: CreateOptions{
93 Description: "",
94 Public: false,
95 Filenames: []string{"-"},
96 },
97 wantsErr: false,
98 },
99 {
100 name: "with description",
101 cli: `-d "my new gist" -`,
102 wants: CreateOptions{
103 Description: "my new gist",
104 Public: false,
105 Filenames: []string{"-"},
106 },
107 wantsErr: false,
108 },
109 {
110 name: "public",
111 cli: `--public -`,
112 wants: CreateOptions{
113 Description: "",
114 Public: true,

Callers

nothing calls this directly

Calls 6

TestFunction · 0.92
SetStdinTTYMethod · 0.80
EqualMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected