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

Function TestParseMultiStringSliceFromEnvWithDefaults

flag_test.go:1955–1969  ·  flag_test.go::TestParseMultiStringSliceFromEnvWithDefaults
(t *testing.T)

Source from the content-addressed store, hash-verified

1953}
1954
1955func TestParseMultiStringSliceFromEnvWithDefaults(t *testing.T) {
1956 t.Setenv("APP_INTERVALS", "20,30,40")
1957
1958 _ = (&Command{
1959 Flags: []Flag{
1960 &StringSliceFlag{Name: "intervals", Aliases: []string{"i"}, Value: []string{"1", "2", "5"}, Sources: EnvVars("APP_INTERVALS")},
1961 },
1962 Action: func(_ context.Context, cmd *Command) error {
1963 expected := []string{"20", "30", "40"}
1964 assert.Equal(t, expected, cmd.StringSlice("intervals"), "main name not set from env")
1965 assert.Equal(t, expected, cmd.StringSlice("i"), "short name not set from env")
1966 return nil
1967 },
1968 }).Run(buildTestContext(t), []string{"run"})
1969}
1970
1971func TestParseMultiStringSliceFromEnvCascade(t *testing.T) {
1972 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