Commit 85e615bb authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: a lot more provisioner tests

parent b25ae21e
......@@ -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
......
{
"builders": [{
"type": "test"
}],
"provisioners": [{
"type": "test",
"only": ["test"]
}]
}
{
"builders": [{
"type": "test"
}],
"provisioners": [{
"type": "test",
"only": ["foo"]
}]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment