github.com/phobos182/packer@v0.2.3-0.20130819023704-c84d2aeffc68/packer/plugin/hook_test.go (about) 1 package plugin 2 3 import ( 4 "github.com/mitchellh/packer/packer" 5 "os/exec" 6 "testing" 7 ) 8 9 type helperHook byte 10 11 func (helperHook) Run(string, packer.Ui, packer.Communicator, interface{}) error { 12 return nil 13 } 14 15 func TestHook_NoExist(t *testing.T) { 16 c := NewClient(&ClientConfig{Cmd: exec.Command("i-should-not-exist")}) 17 defer c.Kill() 18 19 _, err := c.Hook() 20 if err == nil { 21 t.Fatal("should have error") 22 } 23 } 24 25 func TestHook_Good(t *testing.T) { 26 c := NewClient(&ClientConfig{Cmd: helperProcess("hook")}) 27 defer c.Kill() 28 29 _, err := c.Hook() 30 if err != nil { 31 t.Fatalf("should not have error: %s", err) 32 } 33 }