2013-12-24 16:26:44 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2018-01-22 19:03:49 -05:00
|
|
|
"context"
|
2013-12-24 16:26:44 -05:00
|
|
|
"testing"
|
|
|
|
|
2020-11-17 19:31:03 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
2013-12-24 16:26:44 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
2018-01-22 19:03:49 -05:00
|
|
|
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
2013-12-24 16:26:44 -05:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|