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

Function TestNewCmdCreate

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

Source from the content-addressed store, hash-verified

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