diff --git a/packer_test/dag_tests/mix_data_locals_test.go b/packer_test/dag_tests/mix_data_locals_test.go new file mode 100644 index 000000000..6f7f5d398 --- /dev/null +++ b/packer_test/dag_tests/mix_data_locals_test.go @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + + "github.com/hashicorp/packer/packer_test/common/check" +) + +func (ts *PackerDAGTestSuite) TestWithBothDataLocalMixedOrder() { + pluginDir := ts.MakePluginDir() + defer pluginDir.Cleanup() + + for _, cmd := range []string{"build", "validate"} { + ts.Run(fmt.Sprintf("%s: evaluating with DAG - success expected", cmd), func() { + ts.PackerCommand().UsePluginDir(pluginDir). + SetArgs(cmd, "./templates/mixed_data_local.pkr.hcl"). + Assert(check.MustSucceed()) + }) + + ts.Run(fmt.Sprintf("%s: evaluating sequentially - failure expected", cmd), func() { + ts.PackerCommand().UsePluginDir(pluginDir). + SetArgs(cmd, "--use-sequential-evaluation", "./templates/mixed_data_local.pkr.hcl"). + Assert(check.MustFail()) + }) + } +} diff --git a/packer_test/dag_tests/suite_test.go b/packer_test/dag_tests/suite_test.go new file mode 100644 index 000000000..5083a0e4f --- /dev/null +++ b/packer_test/dag_tests/suite_test.go @@ -0,0 +1,23 @@ +package main + +import ( + "testing" + + "github.com/hashicorp/packer/packer_test/common" + "github.com/stretchr/testify/suite" +) + +type PackerDAGTestSuite struct { + *common.PackerTestSuite +} + +func Test_PackerDAGSuite(t *testing.T) { + baseSuite, cleanup := common.InitBaseSuite(t) + defer cleanup() + + ts := &PackerDAGTestSuite{ + baseSuite, + } + + suite.Run(t, ts) +} diff --git a/packer_test/dag_tests/templates/mixed_data_local.pkr.hcl b/packer_test/dag_tests/templates/mixed_data_local.pkr.hcl new file mode 100644 index 000000000..a0447538e --- /dev/null +++ b/packer_test/dag_tests/templates/mixed_data_local.pkr.hcl @@ -0,0 +1,23 @@ +data "null" "head" { + input = "foo" +} + +locals { + loc = "${data.null.head.output}" +} + +data "null" "tail" { + input = "${local.loc}" +} + +locals { + last = "final - ${data.null.tail.output}" +} + +source "null" "test" { + communicator = "none" +} + +build { + sources = ["null.test"] +}