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

Function TestParseMultiIntSliceFromEnv

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

Source from the content-addressed store, hash-verified

2119}
2120
2121func TestParseMultiIntSliceFromEnv(t *testing.T) {
2122 t.Setenv("APP_INTERVALS", "20,30,40")
2123
2124 _ = (&Command{
2125 Flags: []Flag{
2126 &Int64SliceFlag{Name: "intervals", Aliases: []string{"i"}, Value: []int64{}, Sources: EnvVars("APP_INTERVALS")},
2127 },
2128 Action: func(_ context.Context, cmd *Command) error {
2129 r := require.New(t)
2130
2131 r.Equalf([]int64{20, 30, 40}, cmd.Int64Slice("intervals"), "main name not set from env")
2132 r.Equalf([]int64{20, 30, 40}, cmd.Int64Slice("i"), "short name not set from env")
2133
2134 return nil
2135 },
2136 }).Run(buildTestContext(t), []string{"run"})
2137}
2138
2139func TestParseMultiIntSliceFromEnvWithDefaults(t *testing.T) {
2140 t.Setenv("APP_INTERVALS", "20,30,40")

Callers

nothing calls this directly

Calls 4

EnvVarsFunction · 0.85
buildTestContextFunction · 0.85
Int64SliceMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected