2013-06-18 16:49:07 -04:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
import (
|
2019-03-22 09:56:02 -04:00
|
|
|
"context"
|
2013-06-18 16:49:07 -04:00
|
|
|
"os/exec"
|
|
|
|
"testing"
|
2018-01-22 20:21:10 -05:00
|
|
|
|
|
|
|
"github.com/hashicorp/packer/packer"
|
2013-06-18 16:49:07 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type helperPostProcessor byte
|
|
|
|
|
2013-07-01 17:59:23 -04:00
|
|
|
func (helperPostProcessor) Configure(...interface{}) error {
|
2013-06-18 16:49:07 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-08 13:59:42 -04:00
|
|
|
func (helperPostProcessor) PostProcess(context.Context, packer.Ui, packer.Artifact) (packer.Artifact, bool, bool, error) {
|
2019-04-03 14:32:49 -04:00
|
|
|
return nil, false, false, nil
|
2013-06-18 16:49:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestPostProcessor_NoExist(t *testing.T) {
|
|
|
|
c := NewClient(&ClientConfig{Cmd: exec.Command("i-should-not-exist")})
|
|
|
|
defer c.Kill()
|
|
|
|
|
|
|
|
_, err := c.PostProcessor()
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("should have error")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPostProcessor_Good(t *testing.T) {
|
|
|
|
c := NewClient(&ClientConfig{Cmd: helperProcess("post-processor")})
|
|
|
|
defer c.Kill()
|
|
|
|
|
|
|
|
_, err := c.PostProcessor()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("should not have error: %s", err)
|
|
|
|
}
|
|
|
|
}
|