builder/virtualbox: tests for StepUploadVerison
This commit is contained in:
parent
5f1c597269
commit
e51dde13ce
|
@ -0,0 +1,61 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStepUploadVersion_impl(t *testing.T) {
|
||||
var _ multistep.Step = new(StepUploadVersion)
|
||||
}
|
||||
|
||||
func TestStepUploadVersion(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepUploadVersion)
|
||||
step.Path = "foopath"
|
||||
|
||||
comm := new(packer.MockCommunicator)
|
||||
state.Put("communicator", comm)
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
driver.VersionResult = "foo"
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Verify
|
||||
if comm.UploadPath != "foopath" {
|
||||
t.Fatalf("bad: %#v", comm.UploadPath)
|
||||
}
|
||||
if comm.UploadData != "foo" {
|
||||
t.Fatalf("upload data bad: %#v", comm.UploadData)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepUploadVersion_noPath(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepUploadVersion)
|
||||
step.Path = ""
|
||||
|
||||
comm := new(packer.MockCommunicator)
|
||||
state.Put("communicator", comm)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Verify
|
||||
if comm.UploadCalled {
|
||||
t.Fatal("bad")
|
||||
}
|
||||
}
|
|
@ -27,14 +27,14 @@ type Builder struct {
|
|||
}
|
||||
|
||||
type config struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
vboxcommon.ExportConfig `mapstructure:",squash"`
|
||||
vboxcommon.FloppyConfig `mapstructure:",squash"`
|
||||
vboxcommon.OutputConfig `mapstructure:",squash"`
|
||||
vboxcommon.RunConfig `mapstructure:",squash"`
|
||||
vboxcommon.ShutdownConfig `mapstructure:",squash"`
|
||||
vboxcommon.SSHConfig `mapstructure:",squash"`
|
||||
vboxcommon.VBoxManageConfig `mapstructure:",squash"`
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
vboxcommon.ExportConfig `mapstructure:",squash"`
|
||||
vboxcommon.FloppyConfig `mapstructure:",squash"`
|
||||
vboxcommon.OutputConfig `mapstructure:",squash"`
|
||||
vboxcommon.RunConfig `mapstructure:",squash"`
|
||||
vboxcommon.ShutdownConfig `mapstructure:",squash"`
|
||||
vboxcommon.SSHConfig `mapstructure:",squash"`
|
||||
vboxcommon.VBoxManageConfig `mapstructure:",squash"`
|
||||
vboxcommon.VBoxVersionConfig `mapstructure:",squash"`
|
||||
|
||||
BootCommand []string `mapstructure:"boot_command"`
|
||||
|
|
|
@ -8,14 +8,14 @@ import (
|
|||
|
||||
// Config is the configuration structure for the builder.
|
||||
type Config struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
vboxcommon.ExportConfig `mapstructure:",squash"`
|
||||
vboxcommon.FloppyConfig `mapstructure:",squash"`
|
||||
vboxcommon.OutputConfig `mapstructure:",squash"`
|
||||
vboxcommon.RunConfig `mapstructure:",squash"`
|
||||
vboxcommon.SSHConfig `mapstructure:",squash"`
|
||||
vboxcommon.ShutdownConfig `mapstructure:",squash"`
|
||||
vboxcommon.VBoxManageConfig `mapstructure:",squash"`
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
vboxcommon.ExportConfig `mapstructure:",squash"`
|
||||
vboxcommon.FloppyConfig `mapstructure:",squash"`
|
||||
vboxcommon.OutputConfig `mapstructure:",squash"`
|
||||
vboxcommon.RunConfig `mapstructure:",squash"`
|
||||
vboxcommon.SSHConfig `mapstructure:",squash"`
|
||||
vboxcommon.ShutdownConfig `mapstructure:",squash"`
|
||||
vboxcommon.VBoxManageConfig `mapstructure:",squash"`
|
||||
vboxcommon.VBoxVersionConfig `mapstructure:",squash"`
|
||||
|
||||
tpl *packer.ConfigTemplate
|
||||
|
|
Loading…
Reference in New Issue