MCPcopy Index your code
hub / github.com/cli/cli / TestNewCmdWatch

Function TestNewCmdWatch

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

Source from the content-addressed store, hash-verified

20)
21
22func 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 }

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