(t *testing.T)
| 20 | ) |
| 21 | |
| 22 | func 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) |
nothing calls this directly
no test coverage detected