MCPcopy
hub / github.com/urfave/cli / TestCommand_Uint64Slice

Function TestCommand_Uint64Slice

flag_uint_slice_test.go:207–254  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

205}
206
207func TestCommand_Uint64Slice(t *testing.T) {
208 tests := []struct {
209 name string
210 flag Flag
211 arguments []string
212 expect []uint64
213 expectErr bool
214 }{
215 {
216 flag: &Uint64SliceFlag{
217 Name: "numbers",
218 },
219 arguments: []string{"--numbers", "1,2,3,4"},
220 expect: []uint64{1, 2, 3, 4},
221 },
222 {
223 flag: &Uint64SliceFlag{
224 Name: "numbers",
225 },
226 arguments: []string{"--numbers", "1,2", "--numbers", "3,4"},
227 expect: []uint64{1, 2, 3, 4},
228 },
229 }
230 for _, tt := range tests {
231 t.Run(tt.name, func(t *testing.T) {
232 cmd := &Command{
233 Name: "mock",
234 Flags: []Flag{tt.flag},
235 Writer: io.Discard,
236 ErrWriter: io.Discard,
237 }
238
239 err := cmd.Run(buildTestContext(t), append([]string{"mock"}, tt.arguments...))
240
241 if tt.expectErr {
242 require.Error(t, err)
243
244 return
245 }
246
247 require.NoError(t, err)
248
249 for _, name := range tt.flag.Names() {
250 assert.Equalf(t, tt.expect, cmd.Uint64Slice(name), "Uint64Slice(%v)", name)
251 }
252 })
253 }
254}

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
Uint64SliceMethod · 0.95
buildTestContextFunction · 0.85
NamesMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected