2020-03-13 12:10:51 -04:00
|
|
|
package shell_test
|
2020-03-13 11:17:40 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
2020-03-13 12:17:42 -04:00
|
|
|
|
|
|
|
"github.com/hashicorp/go-uuid"
|
|
|
|
"github.com/hashicorp/packer/command"
|
2020-03-13 12:52:33 -04:00
|
|
|
testshelper "github.com/hashicorp/packer/helper/tests"
|
2020-03-13 11:17:40 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuildShellProvisionerWithBuildVariablesSharing(t *testing.T) {
|
2020-03-13 12:50:05 -04:00
|
|
|
testshelper.AccTestPreValidate(t)
|
|
|
|
|
2020-03-13 11:17:40 -04:00
|
|
|
UUID, _ := uuid.GenerateUUID()
|
|
|
|
os.Setenv("PACKER_RUN_UUID", UUID)
|
|
|
|
c := &command.BuildCommand{
|
2020-03-13 11:35:31 -04:00
|
|
|
Meta: testshelper.TestMetaFile(t),
|
2020-03-13 11:17:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
file := "provisioner.shell." + UUID + ".txt"
|
2020-03-13 11:35:31 -04:00
|
|
|
defer testshelper.CleanupFiles(file)
|
2020-03-13 11:17:40 -04:00
|
|
|
|
|
|
|
args := []string{
|
|
|
|
filepath.Join("./test-fixtures", "shell-provisioner.json"),
|
|
|
|
}
|
|
|
|
if code := c.Run(args); code != 0 {
|
2020-03-13 11:35:31 -04:00
|
|
|
testshelper.FatalCommand(t, c.Meta)
|
2020-03-13 11:17:40 -04:00
|
|
|
}
|
|
|
|
|
2020-03-13 11:35:31 -04:00
|
|
|
if !testshelper.FileExists(file) {
|
2020-03-13 11:17:40 -04:00
|
|
|
t.Errorf("Expected to find %s", file)
|
|
|
|
} else {
|
|
|
|
helper := testshelper.AWSHelper{
|
|
|
|
Region: "us-east-1",
|
|
|
|
AMIName: "packer-test-shell-interpolate",
|
|
|
|
}
|
|
|
|
helper.CleanUpAmi(t)
|
|
|
|
}
|
|
|
|
}
|