MCPcopy
hub / github.com/cli/cli / TestNewCmdCreate

Function TestNewCmdCreate

pkg/cmd/discussion/create/create_test.go:18–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestNewCmdCreate(t *testing.T) {
19 tests := []struct {
20 name string
21 args string
22 isTTY bool
23 wantOpts CreateOptions
24 wantBaseRepo ghrepo.Interface
25 wantErr string
26 }{
27 {
28 name: "no flags",
29 args: "",
30 isTTY: true,
31 wantOpts: CreateOptions{},
32 },
33 {
34 name: "all flags",
35 args: "--title 'My question' --body 'Details' --category 'Q&A' --label bug,enhancement",
36 isTTY: true,
37 wantOpts: CreateOptions{
38 Title: "My question",
39 Body: "Details",
40 Category: "Q&A",
41 Labels: []string{"bug", "enhancement"},
42 },
43 },
44 {
45 name: "extra args",
46 args: "extra",
47 isTTY: true,
48 wantErr: "unknown argument",
49 },
50 {
51 name: "missing required flags non-interactively",
52 args: "--title 'My question'",
53 isTTY: false,
54 wantErr: "--title, --body (or --body-file), and --category are required when not running interactively",
55 },
56 {
57 name: "blank title",
58 args: "--title ' '",
59 isTTY: true,
60 wantErr: "title cannot be blank",
61 },
62 {
63 name: "blank category",
64 args: "--category ' '",
65 isTTY: true,
66 wantErr: "category cannot be blank",
67 },
68 {
69 name: "blank body",
70 args: "--body ' '",
71 isTTY: true,
72 wantErr: "body cannot be blank",
73 },
74 {
75 name: "body and body-file mutually exclusive",

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
ContainsMethod · 0.80
EqualMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65
BaseRepoMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected