41 lines
835 B
Go
Raw Permalink Normal View History

2015-06-13 17:50:45 -04:00
package communicator
import (
"bytes"
2018-01-22 16:03:49 -08:00
"context"
2015-06-13 17:50:45 -04:00
"testing"
2020-11-17 16:31:03 -08:00
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
2015-06-13 17:50:45 -04:00
)
func TestStepConnect_impl(t *testing.T) {
var _ multistep.Step = new(StepConnect)
}
func TestStepConnect_none(t *testing.T) {
state := testState(t)
step := &StepConnect{
Config: &Config{
Type: "none",
},
}
defer step.Cleanup(state)
// run the step
2018-01-22 16:03:49 -08:00
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
2015-06-13 17:50:45 -04:00
t.Fatalf("bad action: %#v", action)
}
}
func testState(t *testing.T) multistep.StateBag {
state := new(multistep.BasicStateBag)
state.Put("hook", &packersdk.MockHook{})
state.Put("ui", &packersdk.BasicUi{
2015-06-13 17:50:45 -04:00
Reader: new(bytes.Buffer),
Writer: new(bytes.Buffer),
})
return state
}