MCPcopy Create free account
hub / github.com/cli/cli / TestNewCmdWatch

Function TestNewCmdWatch

pkg/cmd/run/watch/watch_test.go:23–109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
NewCmdWatchFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected