github.com/HashDataInc/packer@v1.3.2/packer/plugin/hook_test.go (about)

     1  package plugin
     2  
     3  import (
     4  	"os/exec"
     5  	"testing"
     6  )
     7  
     8  func TestHook_NoExist(t *testing.T) {
     9  	c := NewClient(&ClientConfig{Cmd: exec.Command("i-should-not-exist")})
    10  	defer c.Kill()
    11  
    12  	_, err := c.Hook()
    13  	if err == nil {
    14  		t.Fatal("should have error")
    15  	}
    16  }
    17  
    18  func TestHook_Good(t *testing.T) {
    19  	c := NewClient(&ClientConfig{Cmd: helperProcess("hook")})
    20  	defer c.Kill()
    21  
    22  	_, err := c.Hook()
    23  	if err != nil {
    24  		t.Fatalf("should not have error: %s", err)
    25  	}
    26  }