Merge pull request #4324 from KohlsTechnology/add-puppet-unit-tests

Add additional unit tests for puppet provisioners
This commit is contained in:
Rickard von Essen 2016-12-27 08:40:14 +01:00 committed by GitHub
commit 77f878b89c
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()