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

Function Test_NewCmdReady

pkg/cmd/pr/ready/ready_test.go:21–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func Test_NewCmdReady(t *testing.T) {
22 tests := []struct {
23 name string
24 args string
25 isTTY bool
26 want ReadyOptions
27 wantErr string
28 }{
29 {
30 name: "number argument",
31 args: "123",
32 isTTY: true,
33 want: ReadyOptions{
34 SelectorArg: "123",
35 },
36 },
37 {
38 name: "no argument",
39 args: "",
40 isTTY: true,
41 want: ReadyOptions{
42 SelectorArg: "",
43 },
44 },
45 {
46 name: "no argument with --repo override",
47 args: "-R owner/repo",
48 isTTY: true,
49 wantErr: "argument required when using the --repo flag",
50 },
51 }
52 for _, tt := range tests {
53 t.Run(tt.name, func(t *testing.T) {
54 ios, _, _, _ := iostreams.Test()
55 ios.SetStdoutTTY(tt.isTTY)
56 ios.SetStdinTTY(tt.isTTY)
57 ios.SetStderrTTY(tt.isTTY)
58
59 f := &cmdutil.Factory{
60 IOStreams: ios,
61 }
62
63 var opts *ReadyOptions
64 cmd := NewCmdReady(f, func(o *ReadyOptions) error {
65 opts = o
66 return nil
67 })
68 cmd.PersistentFlags().StringP("repo", "R", "", "")
69
70 argv, err := shlex.Split(tt.args)
71 require.NoError(t, err)
72 cmd.SetArgs(argv)
73
74 cmd.SetIn(&bytes.Buffer{})
75 cmd.SetOut(io.Discard)
76 cmd.SetErr(io.Discard)
77
78 _, err = cmd.ExecuteC()

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
NewCmdReadyFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected