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

Function TestParseMultiStringSliceFromEnv

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

Source from the content-addressed store, hash-verified

1937}
1938
1939func TestParseMultiStringSliceFromEnv(t *testing.T) {
1940 t.Setenv("APP_INTERVALS", "20,30,40")
1941
1942 _ = (&Command{
1943 Flags: []Flag{
1944 &StringSliceFlag{Name: "intervals", Aliases: []string{"i"}, Value: []string{}, Sources: EnvVars("APP_INTERVALS")},
1945 },
1946 Action: func(_ context.Context, cmd *Command) error {
1947 expected := []string{"20", "30", "40"}
1948 assert.Equal(t, expected, cmd.StringSlice("intervals"), "main name not set from env")
1949 assert.Equal(t, expected, cmd.StringSlice("i"), "short name not set from env")
1950 return nil
1951 },
1952 }).Run(buildTestContext(t), []string{"run"})
1953}
1954
1955func TestParseMultiStringSliceFromEnvWithDefaults(t *testing.T) {
1956 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