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

Function TestFlagAction

command_test.go:3255–3573  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3253}
3254
3255func TestFlagAction(t *testing.T) {
3256 now := time.Now().UTC().Truncate(time.Minute)
3257 testCases := []struct {
3258 name string
3259 args []string
3260 err string
3261 exp string
3262 }{
3263 {
3264 name: "flag_string",
3265 args: []string{"app", "--f_string=string"},
3266 exp: "string ",
3267 },
3268 {
3269 name: "flag_string_error",
3270 args: []string{"app", "--f_string="},
3271 err: "empty string",
3272 },
3273 {
3274 name: "flag_string_error2",
3275 args: []string{"app", "--f_string=", "--f_bool"},
3276 err: "empty string",
3277 },
3278 {
3279 name: "flag_string_slice",
3280 args: []string{"app", "--f_string_slice=s1,s2,s3"},
3281 exp: "[s1 s2 s3] ",
3282 },
3283 {
3284 name: "flag_string_slice_error",
3285 args: []string{"app", "--f_string_slice=err"},
3286 err: "error string slice",
3287 },
3288 {
3289 name: "flag_bool",
3290 args: []string{"app", "--f_bool"},
3291 exp: "true ",
3292 },
3293 {
3294 name: "flag_bool_error",
3295 args: []string{"app", "--f_bool=false"},
3296 err: "value is false",
3297 },
3298 {
3299 name: "flag_duration",
3300 args: []string{"app", "--f_duration=1h30m20s"},
3301 exp: "1h30m20s ",
3302 },
3303 {
3304 name: "flag_duration_error",
3305 args: []string{"app", "--f_duration=0"},
3306 err: "empty duration",
3307 },
3308 {
3309 name: "flag_float64",
3310 args: []string{"app", "--f_float64=3.14159"},
3311 exp: "3.14159 ",
3312 },

Callers

nothing calls this directly

Calls 6

RunMethod · 0.95
RootMethod · 0.95
buildTestContextFunction · 0.85
WriteMethod · 0.80
FormatMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected