github.com/emate/packer@v0.8.1-0.20150625195101-fe0fde195dc6/helper/communicator/config_test.go (about) 1 package communicator 2 3 import ( 4 "testing" 5 6 "github.com/mitchellh/packer/template/interpolate" 7 ) 8 9 func testConfig() *Config { 10 return &Config{ 11 SSHUsername: "root", 12 } 13 } 14 15 func TestConfigType(t *testing.T) { 16 c := testConfig() 17 if err := c.Prepare(testContext(t)); len(err) > 0 { 18 t.Fatalf("bad: %#v", err) 19 } 20 21 if c.Type != "ssh" { 22 t.Fatalf("bad: %#v", c) 23 } 24 } 25 26 func TestConfig_none(t *testing.T) { 27 c := &Config{Type: "none"} 28 if err := c.Prepare(testContext(t)); len(err) > 0 { 29 t.Fatalf("bad: %#v", err) 30 } 31 } 32 33 func testContext(t *testing.T) *interpolate.Context { 34 return nil 35 }