mirror of https://github.com/hashicorp/packer
parent
d545431f9b
commit
4b4fe2280d
@ -0,0 +1,28 @@
|
||||
package communicator
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/packer/template/interpolate"
|
||||
)
|
||||
|
||||
func testConfig() *Config {
|
||||
return &Config{
|
||||
SSHUsername: "root",
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigType(t *testing.T) {
|
||||
c := testConfig()
|
||||
if err := c.Prepare(testContext(t)); len(err) > 0 {
|
||||
t.Fatalf("bad: %#v", err)
|
||||
}
|
||||
|
||||
if c.Type != "ssh" {
|
||||
t.Fatal("bad: %#v", c)
|
||||
}
|
||||
}
|
||||
|
||||
func testContext(t *testing.T) *interpolate.Context {
|
||||
return nil
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package communicator
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
)
|
||||
|
||||
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
|
||||
if action := step.Run(state); action != multistep.ActionContinue {
|
||||
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
|
||||
}
|
||||
Loading…
Reference in new issue