Files

43 lines
963 B
Go
Raw Permalink Normal View History

package packer
2013-06-18 13:49:07 -07:00
import (
2019-03-22 14:56:02 +01:00
"context"
2013-06-18 13:49:07 -07:00
"os/exec"
"testing"
2018-01-22 17:21:10 -08:00
2019-12-17 11:25:56 +01:00
"github.com/hashicorp/hcl/v2/hcldec"
2020-12-17 13:29:25 -08:00
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
2013-06-18 13:49:07 -07:00
)
type helperPostProcessor byte
2019-12-17 11:25:56 +01:00
func (helperPostProcessor) ConfigSpec() hcldec.ObjectSpec { return nil }
func (helperPostProcessor) Configure(...interface{}) error {
2013-06-18 13:49:07 -07:00
return nil
}
2020-11-19 12:17:11 -08:00
func (helperPostProcessor) PostProcess(context.Context, packersdk.Ui, packersdk.Artifact) (packersdk.Artifact, bool, bool, error) {
2019-04-03 11:32:49 -07:00
return nil, false, false, nil
2013-06-18 13:49:07 -07:00
}
func TestPostProcessor_NoExist(t *testing.T) {
c := NewClient(&PluginClientConfig{Cmd: exec.Command("i-should-not-exist")})
2013-06-18 13:49:07 -07:00
defer c.Kill()
_, err := c.PostProcessor()
if err == nil {
t.Fatal("should have error")
}
}
func TestPostProcessor_Good(t *testing.T) {
c := NewClient(&PluginClientConfig{Cmd: helperProcess("post-processor")})
2013-06-18 13:49:07 -07:00
defer c.Kill()
_, err := c.PostProcessor()
if err != nil {
t.Fatalf("should not have error: %s", err)
}
}