fix tests

This commit is contained in:
Megan Marsh 2018-10-25 14:41:01 -07:00
parent 290f4a7c4c
commit 2ae235a28a
6 changed files with 12 additions and 10 deletions

View File

@ -55,7 +55,7 @@ func NewLocalArtifact(id string, dir string) (packer.Artifact, error) {
}, nil
}
func NewArtifact(dir OutputDir, files []string, config map[string]string, esxi bool) (packer.Artifact, error) {
func NewArtifact(vmname string, dir OutputDir, files []string, config map[string]string, esxi bool) (packer.Artifact, error) {
builderID := BuilderId
if esxi {
builderID = BuilderIdESX
@ -63,13 +63,14 @@ func NewArtifact(dir OutputDir, files []string, config map[string]string, esxi b
return &artifact{
builderId: builderID,
id: vmname,
dir: dir.String(),
f: files,
}, nil
}
func (a *artifact) BuilderId() string {
return BuilderId
return a.builderId
}
func (a *artifact) Files() []string {

View File

@ -32,7 +32,8 @@ func TestNewLocalArtifact(t *testing.T) {
dir.SetOutputDir(td)
files, err := dir.ListFiles()
a := NewArtifact(dir, files, false)
config := make(map[string]string)
a, err := NewArtifact("vm1", dir, files, config, false)
if a.BuilderId() != BuilderId {
t.Fatalf("bad: %#v", a.BuilderId())

View File

@ -5,9 +5,9 @@ import (
"net"
"testing"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/helper/config"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/helper/multistep"
)
func TestESX5Driver_implDriver(t *testing.T) {
@ -51,8 +51,9 @@ func TestESX5Driver_HostIP(t *testing.T) {
defer listen.Close()
driver := ESX5Driver{Host: "localhost", Port: uint(port)}
state := new(multistep.BasicStateBag)
if host, _ := driver.HostIP(); host != expected_host {
if host, _ := driver.HostIP(state); host != expected_host {
t.Error(fmt.Sprintf("Expected string, %s but got %s", expected_host, host))
}
}

View File

@ -46,7 +46,6 @@ func (s *StepConfigureVMX) Run(_ context.Context, state multistep.StateBag) mult
// Create a new UUID for this VM, since it is a new VM
vmxData["uuid.action"] = "create"
vmxData["displayname"] = s.VMName
// Delete any generated addresses since we want to regenerate
// them. Conflicting MAC addresses is a bad time.
addrRegex := regexp.MustCompile(`(?i)^ethernet\d+\.generatedAddress`)

View File

@ -411,7 +411,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
config[vmwcommon.ArtifactConfFormat] = b.config.Format
config[vmwcommon.ArtifactConfSkipExport] = strconv.FormatBool(b.config.SkipExport)
return vmwcommon.NewArtifact(dir, files, config, b.config.RemoteType != "")
return vmwcommon.NewArtifact(b.config.VMName, dir, files, config, b.config.RemoteType != "")
}
func (b *Builder) Cancel() {

View File

@ -198,7 +198,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
config[vmwcommon.ArtifactConfFormat] = b.config.Format
config[vmwcommon.ArtifactConfSkipExport] = strconv.FormatBool(b.config.SkipExport)
return vmwcommon.NewArtifact(dir, files, config, b.config.RemoteType != "")
return vmwcommon.NewArtifact(b.config.VMName, dir, files, config, b.config.RemoteType != "")
}
// Cancel.