(t *testing.T)
| 20 | ) |
| 21 | |
| 22 | func TestNewCmdWatch(t *testing.T) { |
| 23 | tests := []struct { |
| 24 | name string |
| 25 | cli string |
| 26 | tty bool |
| 27 | wants WatchOptions |
| 28 | wantsErr bool |
| 29 | }{ |
| 30 | { |
| 31 | name: "blank nontty", |
| 32 | wantsErr: true, |
| 33 | }, |
| 34 | { |
| 35 | name: "blank tty", |
| 36 | tty: true, |
| 37 | wants: WatchOptions{ |
| 38 | Prompt: true, |
| 39 | Interval: defaultInterval, |
| 40 | }, |
| 41 | }, |
| 42 | { |
| 43 | name: "interval", |
| 44 | tty: true, |
| 45 | cli: "-i10", |
| 46 | wants: WatchOptions{ |
| 47 | Interval: 10, |
| 48 | Prompt: true, |
| 49 | }, |
| 50 | }, |
| 51 | { |
| 52 | name: "exit status", |
| 53 | cli: "1234 --exit-status", |
| 54 | wants: WatchOptions{ |
| 55 | Interval: defaultInterval, |
| 56 | RunID: "1234", |
| 57 | ExitStatus: true, |
| 58 | }, |
| 59 | }, |
| 60 | { |
| 61 | name: "compact status", |
| 62 | cli: "1234 --compact", |
| 63 | wants: WatchOptions{ |
| 64 | Interval: defaultInterval, |
| 65 | RunID: "1234", |
| 66 | Compact: true, |
| 67 | }, |
| 68 | }, |
| 69 | } |
| 70 | |
| 71 | for _, tt := range tests { |
| 72 | t.Run(tt.name, func(t *testing.T) { |
| 73 | ios, _, _, _ := iostreams.Test() |
| 74 | ios.SetStdinTTY(tt.tty) |
| 75 | ios.SetStdoutTTY(tt.tty) |
| 76 | |
| 77 | f := &cmdutil.Factory{ |
| 78 | IOStreams: ios, |
| 79 | } |
nothing calls this directly
no test coverage detected