Add help testcase for envprefix + no env.

This commit is contained in:
Connor Hindley
2021-11-17 11:44:13 -07:00
committed by Alec Thomas
parent ea18c73f11
commit 5090305bcb
+3 -1
View File
@@ -463,7 +463,8 @@ func TestEnvarAutoHelp(t *testing.T) {
func TestEnvarAutoHelpWithEnvPrefix(t *testing.T) { func TestEnvarAutoHelpWithEnvPrefix(t *testing.T) {
type Anonymous struct { type Anonymous struct {
Flag string `env:"FLAG" help:"A flag."` Flag string `env:"FLAG" help:"A flag."`
Other string `help:"A different flag."`
} }
var cli struct { var cli struct {
Anonymous `envprefix:"ANON_"` Anonymous `envprefix:"ANON_"`
@@ -473,6 +474,7 @@ func TestEnvarAutoHelpWithEnvPrefix(t *testing.T) {
_, err := p.Parse([]string{"--help"}) _, err := p.Parse([]string{"--help"})
require.NoError(t, err) require.NoError(t, err)
require.Contains(t, w.String(), "A flag ($ANON_FLAG).") require.Contains(t, w.String(), "A flag ($ANON_FLAG).")
require.Contains(t, w.String(), "A different flag.")
} }
func TestCustomHelpFormatter(t *testing.T) { func TestCustomHelpFormatter(t *testing.T) {