Fixes #2699: catch invalid communicator types

pull/2641/merge
Mark Peek 11 years ago
parent 44fd528645
commit 2306f4a4e4

@ -65,6 +65,10 @@ func (c *Config) Prepare(ctx *interpolate.Context) []error {
if es := c.prepareWinRM(ctx); len(es) > 0 {
errs = append(errs, es...)
}
case "none":
break
default:
return []error{fmt.Errorf("Communicator type %s is invalid", c.Type)}
}
return errs

@ -30,6 +30,23 @@ func TestConfig_none(t *testing.T) {
}
}
func TestConfig_badtype(t *testing.T) {
c := &Config{Type: "foo"}
if err := c.Prepare(testContext(t)); len(err) != 1 {
t.Fatalf("bad: %#v", err)
}
}
func TestConfig_winrm(t *testing.T) {
c := &Config{
Type: "winrm",
WinRMUser: "admin",
}
if err := c.Prepare(testContext(t)); len(err) > 0 {
t.Fatalf("bad: %#v", err)
}
}
func testContext(t *testing.T) *interpolate.Context {
return nil
}

Loading…
Cancel
Save