builder/vmware/common: StepSuppressMessages
This commit is contained in:
parent
e5f674a8c2
commit
6cf8d9b319
|
@ -1,18 +1,17 @@
|
||||||
package iso
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
vmwcommon "github.com/mitchellh/packer/builder/vmware/common"
|
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This step suppresses any messages that VMware product might show.
|
// This step suppresses any messages that VMware product might show.
|
||||||
type stepSuppressMessages struct{}
|
type StepSuppressMessages struct{}
|
||||||
|
|
||||||
func (s *stepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction {
|
func (s *StepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
driver := state.Get("driver").(vmwcommon.Driver)
|
driver := state.Get("driver").(Driver)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
vmxPath := state.Get("vmx_path").(string)
|
vmxPath := state.Get("vmx_path").(string)
|
||||||
|
|
||||||
|
@ -27,4 +26,4 @@ func (s *stepSuppressMessages) Run(state multistep.StateBag) multistep.StepActio
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stepSuppressMessages) Cleanup(state multistep.StateBag) {}
|
func (s *StepSuppressMessages) Cleanup(state multistep.StateBag) {}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mitchellh/multistep"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStepSuppressMessages_impl(t *testing.T) {
|
||||||
|
var _ multistep.Step = new(StepSuppressMessages)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStepSuppressMessages(t *testing.T) {
|
||||||
|
state := testState(t)
|
||||||
|
step := new(StepSuppressMessages)
|
||||||
|
|
||||||
|
state.Put("vmx_path", "foo")
|
||||||
|
|
||||||
|
driver := state.Get("driver").(*DriverMock)
|
||||||
|
|
||||||
|
// 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")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the driver
|
||||||
|
if !driver.SuppressMessagesCalled {
|
||||||
|
t.Fatal("should've called")
|
||||||
|
}
|
||||||
|
if driver.SuppressMessagesPath != "foo" {
|
||||||
|
t.Fatal("should call with right path")
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
func testState(t *testing.T) multistep.StateBag {
|
func testState(t *testing.T) multistep.StateBag {
|
||||||
state := new(multistep.BasicStateBag)
|
state := new(multistep.BasicStateBag)
|
||||||
|
state.Put("driver", new(DriverMock))
|
||||||
state.Put("ui", &packer.BasicUi{
|
state.Put("ui", &packer.BasicUi{
|
||||||
Reader: new(bytes.Buffer),
|
Reader: new(bytes.Buffer),
|
||||||
Writer: new(bytes.Buffer),
|
Writer: new(bytes.Buffer),
|
||||||
|
|
|
@ -392,7 +392,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
&vmwcommon.StepConfigureVMX{
|
&vmwcommon.StepConfigureVMX{
|
||||||
CustomData: b.config.VMXData,
|
CustomData: b.config.VMXData,
|
||||||
},
|
},
|
||||||
&stepSuppressMessages{},
|
&vmwcommon.StepSuppressMessages{},
|
||||||
&stepHTTPServer{},
|
&stepHTTPServer{},
|
||||||
&stepConfigureVNC{},
|
&stepConfigureVNC{},
|
||||||
&stepRun{},
|
&stepRun{},
|
||||||
|
|
Loading…
Reference in New Issue