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

Function TestParseMultiStringSliceFromEnvCascadeWithDefaults

flag_test.go:1987–2001  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1985}
1986
1987func TestParseMultiStringSliceFromEnvCascadeWithDefaults(t *testing.T) {
1988 t.Setenv("APP_INTERVALS", "20,30,40")
1989
1990 _ = (&Command{
1991 Flags: []Flag{
1992 &StringSliceFlag{Name: "intervals", Aliases: []string{"i"}, Value: []string{"1", "2", "5"}, Sources: EnvVars("COMPAT_INTERVALS", "APP_INTERVALS")},
1993 },
1994 Action: func(_ context.Context, cmd *Command) error {
1995 expected := []string{"20", "30", "40"}
1996 assert.Equal(t, expected, cmd.StringSlice("intervals"), "main name not set from env")
1997 assert.Equal(t, expected, cmd.StringSlice("i"), "short name not set from env")
1998 return nil
1999 },
2000 }).Run(buildTestContext(t), []string{"run"})
2001}
2002
2003func TestParseMultiStringSliceFromEnvWithDestination(t *testing.T) {
2004 t.Setenv("APP_INTERVALS", "20,30,40")

Callers

nothing calls this directly

Calls 4

EnvVarsFunction · 0.85
buildTestContextFunction · 0.85
StringSliceMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected