2015-06-13 17:50:45 -04:00
|
|
|
package communicator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2018-01-22 19:03:49 -05:00
|
|
|
"context"
|
2015-06-13 17:50:45 -04:00
|
|
|
"testing"
|
|
|
|
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/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 19:03:49 -05: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", &packer.MockHook{})
|
|
|
|
state.Put("ui", &packer.BasicUi{
|
|
|
|
Reader: new(bytes.Buffer),
|
|
|
|
Writer: new(bytes.Buffer),
|
|
|
|
})
|
|
|
|
return state
|
|
|
|
}
|