packer: a lot more provisioner tests
This commit is contained in:
parent
b25ae21e13
commit
85e615bbe2
|
@ -154,6 +154,74 @@ func TestCoreBuild_prov(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCoreBuild_provSkip(t *testing.T) {
|
||||
config := TestCoreConfig(t)
|
||||
testCoreTemplate(t, config, fixtureDir("build-prov-skip.json"))
|
||||
b := TestBuilder(t, config, "test")
|
||||
p := TestProvisioner(t, config, "test")
|
||||
core := TestCore(t, config)
|
||||
|
||||
b.ArtifactId = "hello"
|
||||
|
||||
build, err := core.Build("test")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if _, err := build.Prepare(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
artifact, err := build.Run(nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if len(artifact) != 1 {
|
||||
t.Fatalf("bad: %#v", artifact)
|
||||
}
|
||||
|
||||
if artifact[0].Id() != b.ArtifactId {
|
||||
t.Fatalf("bad: %s", artifact[0].Id())
|
||||
}
|
||||
if p.ProvCalled {
|
||||
t.Fatal("provisioner should not be called")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreBuild_provSkipInclude(t *testing.T) {
|
||||
config := TestCoreConfig(t)
|
||||
testCoreTemplate(t, config, fixtureDir("build-prov-skip-include.json"))
|
||||
b := TestBuilder(t, config, "test")
|
||||
p := TestProvisioner(t, config, "test")
|
||||
core := TestCore(t, config)
|
||||
|
||||
b.ArtifactId = "hello"
|
||||
|
||||
build, err := core.Build("test")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if _, err := build.Prepare(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
artifact, err := build.Run(nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if len(artifact) != 1 {
|
||||
t.Fatalf("bad: %#v", artifact)
|
||||
}
|
||||
|
||||
if artifact[0].Id() != b.ArtifactId {
|
||||
t.Fatalf("bad: %s", artifact[0].Id())
|
||||
}
|
||||
if !p.ProvCalled {
|
||||
t.Fatal("provisioner should be called")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreValidate(t *testing.T) {
|
||||
cases := []struct {
|
||||
File string
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"builders": [{
|
||||
"type": "test"
|
||||
}],
|
||||
|
||||
"provisioners": [{
|
||||
"type": "test",
|
||||
"only": ["test"]
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"builders": [{
|
||||
"type": "test"
|
||||
}],
|
||||
|
||||
"provisioners": [{
|
||||
"type": "test",
|
||||
"only": ["foo"]
|
||||
}]
|
||||
}
|
Loading…
Reference in New Issue