2013-05-11 13:46:17 -04:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"os/exec"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
type helperHook byte
|
|
|
|
|
2013-05-12 20:30:30 -04:00
|
|
|
func (helperHook) Run(string, packer.Ui, packer.Communicator, interface{}) {}
|
2013-05-11 13:46:17 -04:00
|
|
|
|
|
|
|
func TestHook_NoExist(t *testing.T) {
|
2013-06-11 14:00:06 -04:00
|
|
|
c := NewClient(&ClientConfig{Cmd: exec.Command("i-should-not-exist")})
|
|
|
|
defer c.Kill()
|
2013-05-11 13:46:17 -04:00
|
|
|
|
2013-06-11 14:00:06 -04:00
|
|
|
_, err := c.Hook()
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("should have error")
|
|
|
|
}
|
2013-05-11 13:46:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestHook_Good(t *testing.T) {
|
2013-06-11 14:00:06 -04:00
|
|
|
c := NewClient(&ClientConfig{Cmd: helperProcess("hook")})
|
|
|
|
defer c.Kill()
|
2013-05-11 13:46:17 -04:00
|
|
|
|
2013-06-11 14:00:06 -04:00
|
|
|
_, err := c.Hook()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("should not have error: %s", err)
|
|
|
|
}
|
2013-05-11 13:46:17 -04:00
|
|
|
}
|