New test for preparing the new config parameter

This commit is contained in:
Trevor Suarez 2015-11-03 14:36:04 -05:00
parent e41f0bb9f5
commit 84e1b387c4
1 changed files with 31 additions and 1 deletions

View File

@ -1,10 +1,11 @@
package puppetmasterless
import (
"github.com/mitchellh/packer/packer"
"io/ioutil"
"os"
"testing"
"github.com/mitchellh/packer/packer"
)
func testConfig() map[string]interface{} {
@ -177,3 +178,32 @@ func TestProvisionerPrepare_facterFacts(t *testing.T) {
t.Fatalf("err: Default facts are not set in the Puppet provisioner!")
}
}
func TestProvisionerPrepare_options(t *testing.T) {
config := testConfig()
delete(config, "options")
p := new(Provisioner)
err := p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
// Test with malformed fact
config["options"] = "{{}}"
p = new(Provisioner)
err = p.Prepare(config)
if err == nil {
t.Fatal("should be an error")
}
config["options"] = []string{
"arg",
}
p = new(Provisioner)
err = p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
}