packer-cn/helper/communicator/config_test.go

36 lines
586 B
Go
Raw Normal View History

2015-06-13 17:50:45 -04:00
package communicator
import (
"testing"
"github.com/mitchellh/packer/template/interpolate"
)
func testConfig() *Config {
return &Config{
SSHUsername: "root",
}
}
func TestConfigType(t *testing.T) {
c := testConfig()
if err := c.Prepare(testContext(t)); len(err) > 0 {
t.Fatalf("bad: %#v", err)
}
if c.Type != "ssh" {
2015-06-13 19:24:57 -04:00
t.Fatalf("bad: %#v", c)
2015-06-13 17:50:45 -04:00
}
}
func TestConfig_none(t *testing.T) {
c := &Config{Type: "none"}
if err := c.Prepare(testContext(t)); len(err) > 0 {
t.Fatalf("bad: %#v", err)
}
}
2015-06-13 17:50:45 -04:00
func testContext(t *testing.T) *interpolate.Context {
return nil
}