command/output: protect againts blank params

pull/19/head
Mitchell Hashimoto 12 years ago
parent 2caff709d6
commit 3f803cb75c

@ -28,7 +28,7 @@ func (c *OutputCommand) Run(args []string) int {
}
args = cmdFlags.Args()
if len(args) != 1 {
if len(args) != 1 || args[0] == "" {
c.Ui.Error(
"The output command expects exactly one argument with the name\n" +
"of an output variable.\n")

@ -68,6 +68,32 @@ func TestOutput_badVar(t *testing.T) {
}
}
func TestOutput_blank(t *testing.T) {
originalState := &terraform.State{
Outputs: map[string]string{
"foo": "bar",
},
}
statePath := testStateFile(t, originalState)
ui := new(cli.MockUi)
c := &OutputCommand{
Meta: Meta{
ContextOpts: testCtxConfig(testProvider()),
Ui: ui,
},
}
args := []string{
"-state", statePath,
"",
}
if code := c.Run(args); code != 1 {
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
}
}
func TestOutput_manyArgs(t *testing.T) {
ui := new(cli.MockUi)
c := &OutputCommand{

Loading…
Cancel
Save