test for blank args for TF_CLI_ARGS
This commit is contained in:
parent
f7e535ed6e
commit
53796fcdb0
2
main.go
2
main.go
|
@ -153,7 +153,7 @@ func wrappedMain() int {
|
||||||
// after the first non-flag arg.
|
// after the first non-flag arg.
|
||||||
idx := -1
|
idx := -1
|
||||||
for i, v := range args {
|
for i, v := range args {
|
||||||
if v[0] != '-' {
|
if len(v) > 0 && v[0] != '-' {
|
||||||
idx = i
|
idx = i
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
16
main_test.go
16
main_test.go
|
@ -56,6 +56,22 @@ func TestMain_cliArgsFromEnv(t *testing.T) {
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"cli string has blank values",
|
||||||
|
[]string{testCommandName, "bar", "", "baz"},
|
||||||
|
"-foo bar",
|
||||||
|
[]string{"-foo", "bar", "bar", "", "baz"},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"cli string has blank values before the command",
|
||||||
|
[]string{"", testCommandName, "bar"},
|
||||||
|
"-foo bar",
|
||||||
|
[]string{"-foo", "bar", "bar"},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
// this should fail gracefully, this is just testing
|
// this should fail gracefully, this is just testing
|
||||||
// that we don't panic with our slice arithmetic
|
// that we don't panic with our slice arithmetic
|
||||||
|
|
Loading…
Reference in New Issue