packer-cn/packer/plugin/provisioner_test.go

36 lines
694 B
Go
Raw Normal View History

2013-05-24 00:37:16 -04:00
package plugin
import (
"github.com/mitchellh/packer/packer"
"os/exec"
"testing"
)
type helperProvisioner byte
2013-06-06 20:07:42 -04:00
func (helperProvisioner) Prepare(...interface{}) error {
return nil
}
2013-05-24 00:37:16 -04:00
func (helperProvisioner) Provision(packer.Ui, packer.Communicator) {}
func TestProvisioner_NoExist(t *testing.T) {
c := NewClient(&ClientConfig{Cmd: exec.Command("i-should-not-exist")})
defer c.Kill()
2013-05-24 00:37:16 -04:00
_, err := c.Provisioner()
if err == nil {
t.Fatal("should have error")
}
2013-05-24 00:37:16 -04:00
}
func TestProvisioner_Good(t *testing.T) {
c := NewClient(&ClientConfig{Cmd: helperProcess("provisioner")})
defer c.Kill()
2013-05-24 00:37:16 -04:00
_, err := c.Provisioner()
if err != nil {
t.Fatalf("should not have error: %s", err)
}
2013-05-24 00:37:16 -04:00
}