(t *testing.T)
| 25 | } |
| 26 | |
| 27 | func TestNewCmdStatus(t *testing.T) { |
| 28 | tests := []struct { |
| 29 | name string |
| 30 | cli string |
| 31 | wants StatusOptions |
| 32 | }{ |
| 33 | { |
| 34 | name: "defaults", |
| 35 | }, |
| 36 | { |
| 37 | name: "org", |
| 38 | cli: "-o cli", |
| 39 | wants: StatusOptions{ |
| 40 | Org: "cli", |
| 41 | }, |
| 42 | }, |
| 43 | { |
| 44 | name: "exclude", |
| 45 | cli: "-e cli/cli,cli/go-gh", |
| 46 | wants: StatusOptions{ |
| 47 | Exclude: []string{"cli/cli", "cli/go-gh"}, |
| 48 | }, |
| 49 | }, |
| 50 | } |
| 51 | |
| 52 | for _, tt := range tests { |
| 53 | ios, _, _, _ := iostreams.Test() |
| 54 | ios.SetStdinTTY(true) |
| 55 | ios.SetStdoutTTY(true) |
| 56 | |
| 57 | if tt.wants.Exclude == nil { |
| 58 | tt.wants.Exclude = []string{} |
| 59 | } |
| 60 | |
| 61 | f := &cmdutil.Factory{ |
| 62 | IOStreams: ios, |
| 63 | Config: func() (gh.Config, error) { |
| 64 | return config.NewBlankConfig(), nil |
| 65 | }, |
| 66 | } |
| 67 | t.Run(tt.name, func(t *testing.T) { |
| 68 | argv, err := shlex.Split(tt.cli) |
| 69 | assert.NoError(t, err) |
| 70 | |
| 71 | var gotOpts *StatusOptions |
| 72 | cmd := NewCmdStatus(f, func(opts *StatusOptions) error { |
| 73 | gotOpts = opts |
| 74 | return nil |
| 75 | }) |
| 76 | cmd.SetArgs(argv) |
| 77 | cmd.SetIn(&bytes.Buffer{}) |
| 78 | _, err = cmd.ExecuteC() |
| 79 | assert.NoError(t, err) |
| 80 | |
| 81 | assert.Equal(t, tt.wants.Org, gotOpts.Org) |
| 82 | assert.Equal(t, tt.wants.Exclude, gotOpts.Exclude) |
| 83 | }) |
| 84 | } |
nothing calls this directly
no test coverage detected