(t *testing.T)
| 1728 | } |
| 1729 | |
| 1730 | func 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 | |
| 1752 | func TestParseShortOptionBoolError(t *testing.T) { |
| 1753 | cmd := buildMinimalTestCommand() |
nothing calls this directly
no test coverage detected