From 905db043c4b66c8b7c9da71f4a4a19fa6d737435 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Thu, 10 Jan 2019 11:37:41 +0100 Subject: [PATCH] command.TestBuildOnlyFileCommaFlags: create some files using post processors --- command/build_test.go | 21 ++++++++++++------- .../test-fixtures/build-only/template.json | 10 +++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/command/build_test.go b/command/build_test.go index f5ec395f8..e0a22b268 100644 --- a/command/build_test.go +++ b/command/build_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/packer/builder/file" "github.com/hashicorp/packer/packer" + shell_local "github.com/hashicorp/packer/post-processor/shell-local" ) func TestBuildOnlyFileCommaFlags(t *testing.T) { @@ -111,14 +112,15 @@ func TestBuildExceptFileCommaFlags(t *testing.T) { fatalCommand(t, c.Meta) } - if fileExists("chocolate.txt") { - t.Error("Expected NOT to find chocolate.txt") + for _, f := range []string{"chocolate.txt"} { + if fileExists(f) { + t.Errorf("Expected NOT to find %s", f) + } } - if !fileExists("vanilla.txt") { - t.Error("Expected to find vanilla.txt") - } - if !fileExists("cherry.txt") { - t.Error("Expected to find cherry.txt") + for _, f := range []string{"vanilla.txt", "cherry.txt", "apple.txt", "peach.txt"} { + if !fileExists(f) { + t.Errorf("Expected to find %s", f) + } } } @@ -137,6 +139,9 @@ func testCoreConfigBuilder(t *testing.T) *packer.CoreConfig { Builder: func(n string) (packer.Builder, error) { return &file.Builder{}, nil }, + PostProcessor: func(n string) (packer.PostProcessor, error) { + return &shell_local.PostProcessor{}, nil + }, } return &packer.CoreConfig{ Components: components, @@ -159,4 +164,6 @@ func cleanup() { os.RemoveAll("chocolate.txt") os.RemoveAll("vanilla.txt") os.RemoveAll("cherry.txt") + os.RemoveAll("apple.txt") + os.RemoveAll("peach.txt") } diff --git a/command/test-fixtures/build-only/template.json b/command/test-fixtures/build-only/template.json index ee89d635e..e5b0d6d09 100644 --- a/command/test-fixtures/build-only/template.json +++ b/command/test-fixtures/build-only/template.json @@ -18,5 +18,15 @@ "content":"cherry", "target":"cherry.txt" } + ], + "post-processors": [ + { + "type": "shell-local", + "inline": ["touch apple.txt"] + }, + { + "type": "shell-local", + "inline": ["touch peach.txt"] + } ] }