Add additional unit tests for puppet provisioners

* Add puppet-masterless test for packer_build_name default fact
* Add puppet-masterless test for packer_builder_type default fact
* Add puppet-server test for puppet bin directory
This commit is contained in:
Sean Malloy 2016-12-26 23:11:27 -06:00
parent d6892442a8
commit ce43ade973
2 changed files with 33 additions and 0 deletions

View File

@ -203,6 +203,14 @@ func TestProvisionerPrepare_facterFacts(t *testing.T) {
if p.config.Facter == nil {
t.Fatalf("err: Default facts are not set in the Puppet provisioner!")
}
if _, ok := p.config.Facter["packer_build_name"]; !ok {
t.Fatalf("err: packer_build_name fact not set in the Puppet provisioner!")
}
if _, ok := p.config.Facter["packer_builder_type"]; !ok {
t.Fatalf("err: packer_builder_type fact not set in the Puppet provisioner!")
}
}
func TestProvisionerPrepare_extraArguments(t *testing.T) {

View File

@ -26,6 +26,31 @@ func TestProvisioner_Impl(t *testing.T) {
}
}
func TestProvisionerPrepare_puppetBinDir(t *testing.T) {
config := testConfig()
delete(config, "puppet_bin_dir")
p := new(Provisioner)
err := p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
// Test with a good one
tf, err := ioutil.TempFile("", "packer")
if err != nil {
t.Fatalf("error tempfile: %s", err)
}
defer os.Remove(tf.Name())
config["puppet_bin_dir"] = tf.Name()
p = new(Provisioner)
err = p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
}
func TestProvisionerPrepare_clientPrivateKeyPath(t *testing.T) {
config := testConfig()