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

Function TestRangeArgs

pkg/cmdutil/args_test.go:60–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestRangeArgs(t *testing.T) {
61 const msg = "artifact number or URL is required"
62
63 tests := []struct {
64 name string
65 min int
66 max int
67 args []string
68 wantErr string
69 }{
70 {
71 name: "the fewest arguments",
72 min: 1,
73 max: 2,
74 args: []string{"142"},
75 },
76 {
77 name: "the most arguments",
78 min: 1,
79 max: 2,
80 args: []string{"142", "2"},
81 },
82 {
83 name: "a range of one",
84 min: 2,
85 max: 2,
86 args: []string{"142", "2"},
87 },
88 {
89 name: "no arguments",
90 min: 1,
91 max: 2,
92 wantErr: msg,
93 },
94 {
95 name: "fewer than the fewest",
96 min: 2,
97 max: 3,
98 args: []string{"142"},
99 wantErr: msg,
100 },
101 {
102 name: "more than the most",
103 min: 1,
104 max: 2,
105 args: []string{"142", "2", "3"},
106 wantErr: "too many arguments",
107 },
108 }
109
110 for _, tt := range tests {
111 t.Run(tt.name, func(t *testing.T) {
112 err := RangeArgs(tt.min, tt.max, msg)(nil, tt.args)
113
114 if tt.wantErr == "" {
115 require.NoError(t, err)
116 return
117 }

Callers

nothing calls this directly

Calls 2

RangeArgsFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected