2013-05-09 01:25:47 -04:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"os/exec"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
type helperBuilder byte
|
|
|
|
|
2013-06-14 15:27:50 -04:00
|
|
|
func (helperBuilder) Prepare(...interface{}) error {
|
2013-05-09 13:54:42 -04:00
|
|
|
return nil
|
|
|
|
}
|
2013-05-09 01:25:47 -04:00
|
|
|
|
2013-06-12 19:06:56 -04:00
|
|
|
func (helperBuilder) Run(packer.Ui, packer.Hook, packer.Cache) (packer.Artifact, error) {
|
|
|
|
return nil, nil
|
2013-05-22 01:16:26 -04:00
|
|
|
}
|
2013-05-09 01:25:47 -04:00
|
|
|
|
2013-06-03 17:44:34 -04:00
|
|
|
func (helperBuilder) Cancel() {}
|
|
|
|
|
2013-05-09 01:25:47 -04:00
|
|
|
func TestBuilder_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-09 01:25:47 -04:00
|
|
|
|
2013-06-11 14:00:06 -04:00
|
|
|
_, err := c.Builder()
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("should have error")
|
|
|
|
}
|
2013-05-09 01:25:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuilder_Good(t *testing.T) {
|
2013-06-11 14:00:06 -04:00
|
|
|
c := NewClient(&ClientConfig{Cmd: helperProcess("builder")})
|
|
|
|
defer c.Kill()
|
2013-05-09 01:25:47 -04:00
|
|
|
|
2013-06-11 14:00:06 -04:00
|
|
|
_, err := c.Builder()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("should not have error: %s", err)
|
|
|
|
}
|
2013-05-09 01:25:47 -04:00
|
|
|
}
|