Update test to include some interpolation configs

This commit is contained in:
Chris Bednarski 2015-08-04 19:30:57 -07:00
parent 8d6719e71f
commit 4ef3baa3ee
1 changed files with 11 additions and 2 deletions

View File

@ -156,7 +156,7 @@ func TestCompressInterpolation(t *testing.T) {
"post-processors": [ "post-processors": [
{ {
"type": "compress", "type": "compress",
"output": "{{ .BuildName }}.gz" "output": "{{ build_name}}-{{ .BuildName }}-{{.BuilderType}}.gz"
} }
] ]
} }
@ -165,7 +165,9 @@ func TestCompressInterpolation(t *testing.T) {
artifact := testArchive(t, config) artifact := testArchive(t, config)
defer artifact.Destroy() defer artifact.Destroy()
filename := "file.gz" // You can interpolate using the .BuildName variable or build_name global
// function. We'll check both.
filename := "chocolate-vanilla-file.gz"
archive, err := os.Open(filename) archive, err := os.Open(filename)
if err != nil { if err != nil {
t.Fatalf("Unable to read %s: %s", filename, err) t.Fatalf("Unable to read %s: %s", filename, err)
@ -230,6 +232,13 @@ func testArchive(t *testing.T, config string) packer.Artifact {
compressor := PostProcessor{} compressor := PostProcessor{}
compressor.Configure(tpl.PostProcessors[0][0].Config) compressor.Configure(tpl.PostProcessors[0][0].Config)
// I get the feeling these should be automatically available somewhere, but
// some of the post-processors construct this manually.
compressor.config.ctx.BuildName = "chocolate"
compressor.config.PackerBuildName = "vanilla"
compressor.config.PackerBuilderType = "file"
artifactOut, _, err := compressor.PostProcess(ui, artifact) artifactOut, _, err := compressor.PostProcess(ui, artifact)
if err != nil { if err != nil {
t.Fatalf("Failed to compress artifact: %s", err) t.Fatalf("Failed to compress artifact: %s", err)