|
|
@ -6,6 +6,7 @@ import (
|
|
|
|
"reflect"
|
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var boolFlagTests = []struct {
|
|
|
|
var boolFlagTests = []struct {
|
|
|
@ -58,8 +59,12 @@ func TestStringFlagWithEnvVarHelpOutput(t *testing.T) {
|
|
|
|
flag := StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"}
|
|
|
|
flag := StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"}
|
|
|
|
output := flag.String()
|
|
|
|
output := flag.String()
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, " [$APP_FOO]") {
|
|
|
|
expectedSuffix := " [$APP_FOO]"
|
|
|
|
t.Errorf("%s does not end with [$APP_FOO]", output)
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
expectedSuffix = " [%APP_FOO%]"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, expectedSuffix) {
|
|
|
|
|
|
|
|
t.Errorf("%s does not end with" + expectedSuffix, output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -110,8 +115,12 @@ func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) {
|
|
|
|
flag := StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"}
|
|
|
|
flag := StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"}
|
|
|
|
output := flag.String()
|
|
|
|
output := flag.String()
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, " [$APP_QWWX]") {
|
|
|
|
expectedSuffix := " [$APP_QWWX]"
|
|
|
|
t.Errorf("%q does not end with [$APP_QWWX]", output)
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
expectedSuffix = " [%APP_QWWX%]"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, expectedSuffix) {
|
|
|
|
|
|
|
|
t.Errorf("%q does not end with" + expectedSuffix, output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -143,8 +152,12 @@ func TestIntFlagWithEnvVarHelpOutput(t *testing.T) {
|
|
|
|
flag := IntFlag{Name: test.name, EnvVar: "APP_BAR"}
|
|
|
|
flag := IntFlag{Name: test.name, EnvVar: "APP_BAR"}
|
|
|
|
output := flag.String()
|
|
|
|
output := flag.String()
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, " [$APP_BAR]") {
|
|
|
|
expectedSuffix := " [$APP_BAR]"
|
|
|
|
t.Errorf("%s does not end with [$APP_BAR]", output)
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
expectedSuffix = " [%APP_BAR%]"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, expectedSuffix) {
|
|
|
|
|
|
|
|
t.Errorf("%s does not end with" + expectedSuffix, output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -176,8 +189,12 @@ func TestDurationFlagWithEnvVarHelpOutput(t *testing.T) {
|
|
|
|
flag := DurationFlag{Name: test.name, EnvVar: "APP_BAR"}
|
|
|
|
flag := DurationFlag{Name: test.name, EnvVar: "APP_BAR"}
|
|
|
|
output := flag.String()
|
|
|
|
output := flag.String()
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, " [$APP_BAR]") {
|
|
|
|
expectedSuffix := " [$APP_BAR]"
|
|
|
|
t.Errorf("%s does not end with [$APP_BAR]", output)
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
expectedSuffix = " [%APP_BAR%]"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, expectedSuffix) {
|
|
|
|
|
|
|
|
t.Errorf("%s does not end with" + expectedSuffix, output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -216,8 +233,12 @@ func TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) {
|
|
|
|
flag := IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"}
|
|
|
|
flag := IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"}
|
|
|
|
output := flag.String()
|
|
|
|
output := flag.String()
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, " [$APP_SMURF]") {
|
|
|
|
expectedSuffix := " [$APP_SMURF]"
|
|
|
|
t.Errorf("%q does not end with [$APP_SMURF]", output)
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
expectedSuffix = " [%APP_SMURF%]"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, expectedSuffix) {
|
|
|
|
|
|
|
|
t.Errorf("%q does not end with" + expectedSuffix, output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -249,8 +270,12 @@ func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) {
|
|
|
|
flag := Float64Flag{Name: test.name, EnvVar: "APP_BAZ"}
|
|
|
|
flag := Float64Flag{Name: test.name, EnvVar: "APP_BAZ"}
|
|
|
|
output := flag.String()
|
|
|
|
output := flag.String()
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, " [$APP_BAZ]") {
|
|
|
|
expectedSuffix := " [$APP_BAZ]"
|
|
|
|
t.Errorf("%s does not end with [$APP_BAZ]", output)
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
expectedSuffix = " [%APP_BAZ%]"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, expectedSuffix) {
|
|
|
|
|
|
|
|
t.Errorf("%s does not end with" + expectedSuffix, output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -283,8 +308,12 @@ func TestGenericFlagWithEnvVarHelpOutput(t *testing.T) {
|
|
|
|
flag := GenericFlag{Name: test.name, EnvVar: "APP_ZAP"}
|
|
|
|
flag := GenericFlag{Name: test.name, EnvVar: "APP_ZAP"}
|
|
|
|
output := flag.String()
|
|
|
|
output := flag.String()
|
|
|
|
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, " [$APP_ZAP]") {
|
|
|
|
expectedSuffix := " [$APP_ZAP]"
|
|
|
|
t.Errorf("%s does not end with [$APP_ZAP]", output)
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
expectedSuffix = " [%APP_ZAP%]"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasSuffix(output, expectedSuffix) {
|
|
|
|
|
|
|
|
t.Errorf("%s does not end with" + expectedSuffix, output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|