(t *testing.T)
| 1704 | } |
| 1705 | |
| 1706 | func TestParseGenericFromEnv(t *testing.T) { |
| 1707 | t.Setenv("APP_SERVE", "20,30") |
| 1708 | cmd := &Command{ |
| 1709 | Flags: []Flag{ |
| 1710 | &GenericFlag{ |
| 1711 | Name: "serve", |
| 1712 | Aliases: []string{"s"}, |
| 1713 | Value: &Parser{}, |
| 1714 | Sources: EnvVars("APP_SERVE"), |
| 1715 | }, |
| 1716 | }, |
| 1717 | Action: func(ctx context.Context, cmd *Command) error { |
| 1718 | if !reflect.DeepEqual(cmd.Generic("serve"), &Parser{"20", "30"}) { |
| 1719 | t.Errorf("main name not set from env") |
| 1720 | } |
| 1721 | if !reflect.DeepEqual(cmd.Generic("s"), &Parser{"20", "30"}) { |
| 1722 | t.Errorf("short name not set from env") |
| 1723 | } |
| 1724 | return nil |
| 1725 | }, |
| 1726 | } |
| 1727 | assert.NoError(t, cmd.Run(buildTestContext(t), []string{"run"})) |
| 1728 | } |
| 1729 | |
| 1730 | func TestFlagActionFromEnv(t *testing.T) { |
| 1731 | t.Setenv("X", "42") |
nothing calls this directly
no test coverage detected