builder/vmware: better tests around iso_url, test files
This commit is contained in:
parent
62309cb6de
commit
657c3fd87d
|
@ -125,6 +125,11 @@ func (b *Builder) Prepare(raw interface{}) (err error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) == 0 {
|
||||
// Put the URL back together since we may have modified it
|
||||
b.config.ISOUrl = url.String()
|
||||
}
|
||||
}
|
||||
|
||||
if b.config.SSHUser == "" {
|
||||
|
@ -192,6 +197,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) packer
|
|||
|
||||
// Setup the state bag
|
||||
state := make(map[string]interface{})
|
||||
state["cache"] = cache
|
||||
state["config"] = &b.config
|
||||
state["driver"] = b.driver
|
||||
state["hook"] = hook
|
||||
|
|
|
@ -2,6 +2,8 @@ package vmware
|
|||
|
||||
import (
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
@ -97,7 +99,6 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
|
|||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
// Test iso_url
|
||||
config["iso_url"] = ""
|
||||
err := b.Prepare(config)
|
||||
if err == nil {
|
||||
|
@ -121,6 +122,22 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
defer os.Remove(tf.Name())
|
||||
|
||||
config["iso_url"] = tf.Name()
|
||||
err = b.Prepare(config)
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
if b.config.ISOUrl != "file://"+tf.Name() {
|
||||
t.Fatalf("iso_url should be modified: %s", b.config.ISOUrl)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_ShutdownTimeout(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue