github.com/ByteTerrace/packer@v1.3.2/packer/plugin/post_processor_test.go (about)

     1  package plugin
     2  
     3  import (
     4  	"os/exec"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/packer/packer"
     8  )
     9  
    10  type helperPostProcessor byte
    11  
    12  func (helperPostProcessor) Configure(...interface{}) error {
    13  	return nil
    14  }
    15  
    16  func (helperPostProcessor) PostProcess(packer.Ui, packer.Artifact) (packer.Artifact, bool, error) {
    17  	return nil, false, nil
    18  }
    19  
    20  func TestPostProcessor_NoExist(t *testing.T) {
    21  	c := NewClient(&ClientConfig{Cmd: exec.Command("i-should-not-exist")})
    22  	defer c.Kill()
    23  
    24  	_, err := c.PostProcessor()
    25  	if err == nil {
    26  		t.Fatal("should have error")
    27  	}
    28  }
    29  
    30  func TestPostProcessor_Good(t *testing.T) {
    31  	c := NewClient(&ClientConfig{Cmd: helperProcess("post-processor")})
    32  	defer c.Kill()
    33  
    34  	_, err := c.PostProcessor()
    35  	if err != nil {
    36  		t.Fatalf("should not have error: %s", err)
    37  	}
    38  }