MCPcopy
hub / github.com/cli/cli / TestNewCmdGet

Function TestNewCmdGet

pkg/cmd/variable/get/get_test.go:22–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestNewCmdGet(t *testing.T) {
23 tests := []struct {
24 name string
25 cli string
26 wants GetOptions
27 wantErr error
28 }{
29 {
30 name: "repo",
31 cli: "FOO",
32 wants: GetOptions{
33 OrgName: "",
34 VariableName: "FOO",
35 },
36 },
37 {
38 name: "org",
39 cli: "-o TestOrg BAR",
40 wants: GetOptions{
41 OrgName: "TestOrg",
42 VariableName: "BAR",
43 },
44 },
45 {
46 name: "env",
47 cli: "-e Development BAZ",
48 wants: GetOptions{
49 EnvName: "Development",
50 VariableName: "BAZ",
51 },
52 },
53 {
54 name: "org and env",
55 cli: "-o TestOrg -e Development QUX",
56 wantErr: cmdutil.FlagErrorf("%s", "specify only one of `--org` or `--env`"),
57 },
58 {
59 name: "json",
60 cli: "--json name,value FOO",
61 wants: GetOptions{
62 VariableName: "FOO",
63 Exporter: func() cmdutil.Exporter {
64 exporter := cmdutil.NewJSONExporter()
65 exporter.SetFields([]string{"name", "value"})
66 return exporter
67 }(),
68 },
69 },
70 }
71
72 for _, tt := range tests {
73 t.Run(tt.name, func(t *testing.T) {
74 ios, _, _, _ := iostreams.Test()
75 f := &cmdutil.Factory{
76 IOStreams: ios,
77 }
78
79 argv, err := shlex.Split(tt.cli)

Callers

nothing calls this directly

Calls 7

FlagErrorfFunction · 0.92
NewJSONExporterFunction · 0.92
TestFunction · 0.92
NewCmdGetFunction · 0.85
SetFieldsMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected