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

Function TestNewCmdCreateField

pkg/cmd/project/field-create/field_create_test.go:14–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestNewCmdCreateField(t *testing.T) {
15 tests := []struct {
16 name string
17 cli string
18 wants createFieldOpts
19 wantsErr bool
20 wantsErrMsg string
21 wantsExporter bool
22 }{
23 {
24 name: "missing-name-and-data-type",
25 cli: "",
26 wantsErr: true,
27 wantsErrMsg: "required flag(s) \"data-type\", \"name\" not set",
28 },
29 {
30 name: "not-a-number",
31 cli: "x --name n --data-type TEXT",
32 wantsErr: true,
33 wantsErrMsg: "invalid number: x",
34 },
35 {
36 name: "single-select-no-options",
37 cli: "123 --name n --data-type SINGLE_SELECT",
38 wantsErr: true,
39 wantsErrMsg: "passing `--single-select-options` is required for SINGLE_SELECT data type",
40 },
41 {
42 name: "number",
43 cli: "123 --name n --data-type TEXT",
44 wants: createFieldOpts{
45 number: 123,
46 name: "n",
47 dataType: "TEXT",
48 singleSelectOptions: []string{},
49 },
50 },
51 {
52 name: "owner",
53 cli: "--owner monalisa --name n --data-type TEXT",
54 wants: createFieldOpts{
55 owner: "monalisa",
56 name: "n",
57 dataType: "TEXT",
58 singleSelectOptions: []string{},
59 },
60 },
61 {
62 name: "single-select-options",
63 cli: "--name n --data-type TEXT --single-select-options a,b",
64 wants: createFieldOpts{
65 singleSelectOptions: []string{"a", "b"},
66 name: "n",
67 dataType: "TEXT",
68 },
69 },
70 {
71 name: "json",

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
NewCmdCreateFieldFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected