From 8d6719e71fe5fb6b9a31c031c2e5b5849c8b8030 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Mon, 3 Aug 2015 16:34:24 -0700 Subject: [PATCH] Add failing test for compress interpolation --- .../compress/post-processor_test.go | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/post-processor/compress/post-processor_test.go b/post-processor/compress/post-processor_test.go index db23cf3b1..fec3b7a72 100644 --- a/post-processor/compress/post-processor_test.go +++ b/post-processor/compress/post-processor_test.go @@ -150,6 +150,35 @@ func TestCompressOptions(t *testing.T) { } } +func TestCompressInterpolation(t *testing.T) { + const config = ` + { + "post-processors": [ + { + "type": "compress", + "output": "{{ .BuildName }}.gz" + } + ] + } + ` + + artifact := testArchive(t, config) + defer artifact.Destroy() + + filename := "file.gz" + archive, err := os.Open(filename) + if err != nil { + t.Fatalf("Unable to read %s: %s", filename, err) + } + + gzipReader, _ := gzip.NewReader(archive) + data, _ := ioutil.ReadAll(gzipReader) + + if string(data) != expectedFileContents { + t.Errorf("Expected:\n%s\nFound:\n%s\n", expectedFileContents, data) + } +} + // Test Helpers func setup(t *testing.T) (packer.Ui, packer.Artifact, error) {