Fix the CommHost tests
This commit is contained in:
parent
53fef09696
commit
17845beadc
|
@ -4,6 +4,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mitchellh/multistep"
|
||||||
|
"github.com/mitchellh/packer/helper/communicator"
|
||||||
|
"github.com/mitchellh/packer/helper/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestESX5Driver_implDriver(t *testing.T) {
|
func TestESX5Driver_implDriver(t *testing.T) {
|
||||||
|
@ -56,40 +60,31 @@ func TestESX5Driver_HostIP(t *testing.T) {
|
||||||
func TestESX5Driver_CommHost(t *testing.T) {
|
func TestESX5Driver_CommHost(t *testing.T) {
|
||||||
const expected_host = "127.0.0.1"
|
const expected_host = "127.0.0.1"
|
||||||
|
|
||||||
config := make(map[string]interface{})
|
conf := make(map[string]interface{})
|
||||||
config["communicator"] = "winrm"
|
conf["communicator"] = "winrm"
|
||||||
config["winrm_username"] = "username"
|
conf["winrm_username"] = "username"
|
||||||
config["winrm_password"] = "password"
|
conf["winrm_password"] = "password"
|
||||||
config["winrm_host"] = expected_host
|
conf["winrm_host"] = expected_host
|
||||||
|
|
||||||
// var b Builder
|
var commConfig communicator.Config
|
||||||
// warns, err := b.Prepare(config)
|
err := config.Decode(&commConfig, nil, conf)
|
||||||
// if len(warns) > 0 {
|
state := new(multistep.BasicStateBag)
|
||||||
// t.Fatalf("bad: %#v", warns)
|
sshConfig := SSHConfig{Comm: commConfig}
|
||||||
// }
|
state.Put("sshConfig", &sshConfig)
|
||||||
// if err != nil {
|
driver := ESX5Driver{CommConfig: commConfig}
|
||||||
// t.Fatalf("should not have error: %s", err)
|
|
||||||
// }
|
|
||||||
// if host := b.config.CommConfig.Host(); host != expected_host {
|
|
||||||
// t.Fatalf("setup failed, bad host name: %s", host)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// state := new(multistep.BasicStateBag)
|
host, err := driver.CommHost(state)
|
||||||
// state.Put("config", &b.config)
|
if err != nil {
|
||||||
//
|
t.Fatalf("should not have error: %s", err)
|
||||||
// var driver ESX5Driver{}
|
}
|
||||||
// host, err := driver.CommHost(state)
|
if host != expected_host {
|
||||||
// if err != nil {
|
t.Errorf("bad host name: %s", host)
|
||||||
// t.Fatalf("should not have error: %s", err)
|
}
|
||||||
// }
|
address, ok := state.GetOk("vm_address")
|
||||||
// if host != expected_host {
|
if !ok {
|
||||||
// t.Errorf("bad host name: %s", host)
|
t.Error("state not updated with vm_address")
|
||||||
// }
|
}
|
||||||
// address, ok := state.GetOk("vm_address")
|
if address.(string) != expected_host {
|
||||||
// if !ok {
|
t.Errorf("bad vm_address: %s", address.(string))
|
||||||
// t.Error("state not updated with vm_address")
|
}
|
||||||
// }
|
|
||||||
// if address.(string) != expected_host {
|
|
||||||
// t.Errorf("bad vm_address: %s", address.(string))
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue