(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestNewCmdDisable(t *testing.T) { |
| 20 | tests := []struct { |
| 21 | name string |
| 22 | cli string |
| 23 | tty bool |
| 24 | wants DisableOptions |
| 25 | wantsErr bool |
| 26 | }{ |
| 27 | { |
| 28 | name: "blank tty", |
| 29 | tty: true, |
| 30 | wants: DisableOptions{ |
| 31 | Prompt: true, |
| 32 | }, |
| 33 | }, |
| 34 | { |
| 35 | name: "blank nontty", |
| 36 | wantsErr: true, |
| 37 | }, |
| 38 | { |
| 39 | name: "arg tty", |
| 40 | cli: "123", |
| 41 | tty: true, |
| 42 | wants: DisableOptions{ |
| 43 | Selector: "123", |
| 44 | }, |
| 45 | }, |
| 46 | { |
| 47 | name: "arg nontty", |
| 48 | cli: "123", |
| 49 | wants: DisableOptions{ |
| 50 | Selector: "123", |
| 51 | }, |
| 52 | }, |
| 53 | } |
| 54 | |
| 55 | for _, tt := range tests { |
| 56 | t.Run(tt.name, func(t *testing.T) { |
| 57 | ios, _, _, _ := iostreams.Test() |
| 58 | ios.SetStdinTTY(tt.tty) |
| 59 | ios.SetStdoutTTY(tt.tty) |
| 60 | |
| 61 | f := &cmdutil.Factory{ |
| 62 | IOStreams: ios, |
| 63 | } |
| 64 | |
| 65 | argv, err := shlex.Split(tt.cli) |
| 66 | assert.NoError(t, err) |
| 67 | |
| 68 | var gotOpts *DisableOptions |
| 69 | cmd := NewCmdDisable(f, func(opts *DisableOptions) error { |
| 70 | gotOpts = opts |
| 71 | return nil |
| 72 | }) |
| 73 | cmd.SetArgs(argv) |
| 74 | cmd.SetIn(&bytes.Buffer{}) |
| 75 | cmd.SetOut(io.Discard) |
| 76 | cmd.SetErr(io.Discard) |
nothing calls this directly
no test coverage detected