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

Function TestFlagActionFromEnv

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

Source from the content-addressed store, hash-verified

1728}
1729
1730func TestFlagActionFromEnv(t *testing.T) {
1731 t.Setenv("X", "42")
1732 x := 0
1733
1734 cmd := &Command{
1735 Flags: []Flag{
1736 &IntFlag{
1737 Name: "x",
1738 Sources: EnvVars("X"),
1739 Action: func(ctx context.Context, cmd *Command, v int) error {
1740 x = v
1741 return nil
1742 },
1743 },
1744 },
1745 }
1746
1747 assert.NoError(t, cmd.Run(buildTestContext(t), []string{"run"}))
1748 assert.Equal(t, cmd.Int("x"), 42)
1749 assert.Equal(t, x, 42)
1750}
1751
1752func TestParseShortOptionBoolError(t *testing.T) {
1753 cmd := buildMinimalTestCommand()

Callers

nothing calls this directly

Calls 4

RunMethod · 0.95
IntMethod · 0.95
EnvVarsFunction · 0.85
buildTestContextFunction · 0.85

Tested by

no test coverage detected