Beispiel #1
0
func TestIntFlagWithoutDefaultValue(t *testing.T) {
	flag := cli.IntFlag{Name: "help", Usage: "Prints number of help topics", OmitDefaultValue: true}
	output := flag.String()
	expected := "--help \tPrints number of help topics"

	if output != expected {
		t.Errorf("expected '%s' to equal '%s", output, expected)
	}
}
Beispiel #2
0
func TestIntFlagHelpOutput(t *testing.T) {

	for _, test := range intFlagTests {
		flag := cli.IntFlag{Name: test.name}
		output := flag.String()

		if output != test.expected {
			t.Errorf("%s does not match %s", output, test.expected)
		}
	}
}
Beispiel #3
0
func TestIntFlagWithEnvVarHelpOutput(t *testing.T) {

	os.Setenv("APP_BAR", "2")
	for _, test := range intFlagTests {
		flag := cli.IntFlag{Name: test.name, EnvVar: "APP_BAR"}
		output := flag.String()

		if !strings.HasSuffix(output, " [$APP_BAR]") {
			t.Errorf("%s does not end with [$APP_BAR]", output)
		}
	}
}