mirror of https://github.com/hashicorp/packer
Merge pull request #2442 from mitchellh/b-2385
Don't override packer build version with min_packer_version from templatepull/2322/merge
commit
4dccc54191
@ -0,0 +1,10 @@
|
||||
{
|
||||
"builders":[
|
||||
{
|
||||
"type":"file",
|
||||
"target":"chocolate.txt",
|
||||
"content":"chocolate"
|
||||
}
|
||||
],
|
||||
"min_packer_version":"101.0.0"
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestValidateCommandOKVersion(t *testing.T) {
|
||||
c := &ValidateCommand{
|
||||
Meta: testMetaFile(t),
|
||||
}
|
||||
args := []string{
|
||||
filepath.Join(testFixture("validate"), "template.json"),
|
||||
}
|
||||
|
||||
// This should pass with a valid configuration version
|
||||
c.CoreConfig.Version = "102.0.0"
|
||||
if code := c.Run(args); code != 0 {
|
||||
fatalCommand(t, c.Meta)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateCommandBadVersion(t *testing.T) {
|
||||
c := &ValidateCommand{
|
||||
Meta: testMetaFile(t),
|
||||
}
|
||||
args := []string{
|
||||
filepath.Join(testFixture("validate"), "template.json"),
|
||||
}
|
||||
|
||||
// This should fail with an invalid configuration version
|
||||
c.CoreConfig.Version = "100.0.0"
|
||||
if code := c.Run(args); code != 1 {
|
||||
t.Errorf("Expected exit code 1")
|
||||
}
|
||||
|
||||
stdout, stderr := outputCommand(t, c.Meta)
|
||||
expected := `Error initializing core: This template requires Packer version 101.0.0 or higher; using 100.0.0
|
||||
`
|
||||
if stderr != expected {
|
||||
t.Fatalf("Expected:\n%s\nFound:\n%s\n", expected, stderr)
|
||||
}
|
||||
t.Log(stdout)
|
||||
}
|
||||
Loading…
Reference in new issue