From a15ad19411b07f2fd3c59c1782dcbe19fb7301ed Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 7 Jul 2020 11:41:24 +0200 Subject: [PATCH] test builds can be 'excepted' --- command/build_test.go | 17 +++++++++++++++-- command/test-fixtures/hcl/recipes/build.pkr.hcl | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/command/build_test.go b/command/build_test.go index 0724ff036..1a4351d08 100644 --- a/command/build_test.go +++ b/command/build_test.go @@ -28,6 +28,11 @@ carbonara tomato mozza cooking... +` + tiramisu = `whip_york +mascarpone +whipped_egg_white +dress ` ) @@ -254,6 +259,7 @@ func TestBuild(t *testing.T) { expectedContent: map[string]string{ "NULL.spaghetti_carbonara.txt": spaghettiCarbonara, "NULL.lasagna.txt": lasagna, + "NULL.tiramisu.txt": tiramisu, }, }, }, @@ -267,7 +273,8 @@ func TestBuild(t *testing.T) { fileCheck: fileCheck{ notExpected: []string{"NULL.spaghetti_carbonara.txt"}, expectedContent: map[string]string{ - "NULL.lasagna.txt": lasagna, + "NULL.lasagna.txt": lasagna, + "NULL.tiramisu.txt": tiramisu, }, }, }, @@ -279,7 +286,10 @@ func TestBuild(t *testing.T) { testFixture("hcl", "recipes"), }, fileCheck: fileCheck{ - notExpected: []string{"NULL.spaghetti_carbonara.txt"}, + notExpected: []string{ + "NULL.spaghetti_carbonara.txt", + "NULL.tiramisu.txt", + }, expectedContent: map[string]string{ "NULL.lasagna.txt": lasagna, }, @@ -293,6 +303,9 @@ func TestBuild(t *testing.T) { testFixture("hcl", "recipes"), }, fileCheck: fileCheck{ + notExpected: []string{ + "NULL.tiramisu.txt", + }, expectedContent: map[string]string{ "NULL.spaghetti_carbonara.txt": spaghettiCarbonara, "NULL.lasagna.txt": lasagna, diff --git a/command/test-fixtures/hcl/recipes/build.pkr.hcl b/command/test-fixtures/hcl/recipes/build.pkr.hcl index f19bc805d..25a0a5acc 100644 --- a/command/test-fixtures/hcl/recipes/build.pkr.hcl +++ b/command/test-fixtures/hcl/recipes/build.pkr.hcl @@ -3,6 +3,23 @@ build { source "source.null.base" { name = "tiramisu" } + + provisioner "shell-local" { + name = "whipped_york" + inline = [ "echo whip_york > ${upper(build.ID)}.${source.name}.txt" ] + } + provisioner "shell-local" { + name = "mascarpone" + inline = [ "echo mascarpone >> ${upper(build.ID)}.${source.name}.txt" ] + } + post-processor "shell-local" { + name = "whipped_egg_white" + inline = [ "echo whipped_egg_white >> ${upper(build.ID)}.${source.name}.txt" ] + } + post-processor "shell-local" { + name = "dress_with_coffeed_boudoirs" + inline = [ "echo dress >> ${upper(build.ID)}.${source.name}.txt" ] + } } build {