From 28a13111b8f7d6746e95c830e16f6e09cbd73c76 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Mon, 13 Jul 2015 14:57:35 -0700 Subject: [PATCH] Add stub for validate test --- command/test-fixtures/validate/template.json | 10 ++++++ command/validate_test.go | 32 ++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 command/test-fixtures/validate/template.json create mode 100644 command/validate_test.go diff --git a/command/test-fixtures/validate/template.json b/command/test-fixtures/validate/template.json new file mode 100644 index 000000000..1d9e251e5 --- /dev/null +++ b/command/test-fixtures/validate/template.json @@ -0,0 +1,10 @@ +{ + "builders":[ + { + "type":"file", + "target":"chocolate.txt", + "content":"chocolate" + } + ], + "min_packer_version":"0.8.0" +} diff --git a/command/validate_test.go b/command/validate_test.go new file mode 100644 index 000000000..479181fdc --- /dev/null +++ b/command/validate_test.go @@ -0,0 +1,32 @@ +package command + +import ( + "path/filepath" + "testing" +) + +func TestValidateCommand(t *testing.T) { + c := &ValidateCommand{ + Meta: testMetaFile(t), + } + + args := []string{ + filepath.Join(testFixture("validate"), "template.json"), + } + + defer cleanup() + + if code := c.Run(args); code != 0 { + fatalCommand(t, c.Meta) + } + + if !fileExists("chocolate.txt") { + t.Error("Expected to find chocolate.txt") + } + if !fileExists("vanilla.txt") { + t.Error("Expected to find vanilla.txt") + } + if fileExists("cherry.txt") { + t.Error("Expected NOT to find cherry.txt") + } +}