Add additional unit tests for puppet-server provisioner

* Add puppet-server test for staging_dir config option
* Add puppet-server test for execute_command config option
This commit is contained in:
Sean Malloy 2016-12-27 22:35:13 -06:00
parent 77f878b89c
commit c226b19d08
1 changed files with 39 additions and 0 deletions

View File

@ -117,6 +117,17 @@ func TestProvisionerPrepare_clientCertPath(t *testing.T) {
}
}
func TestProvisionerPrepare_executeCommand(t *testing.T) {
config := testConfig()
delete(config, "execute_command")
p := new(Provisioner)
err := p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
}
func TestProvisionerPrepare_facterFacts(t *testing.T) {
config := testConfig()
@ -168,3 +179,31 @@ func TestProvisionerPrepare_facterFacts(t *testing.T) {
t.Fatalf("err: packer_builder_type fact not set in the Puppet provisioner!")
}
}
func TestProvisionerPrepare_stagingDir(t *testing.T) {
config := testConfig()
delete(config, "staging_dir")
p := new(Provisioner)
err := p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
// Make sure the default staging directory is correct
if p.config.StagingDir != "/tmp/packer-puppet-server" {
t.Fatalf("err: Default staging_dir is not set in the Puppet provisioner!")
}
// Make sure default staging directory can be overridden
config["staging_dir"] = "/tmp/override"
p = new(Provisioner)
err = p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
if p.config.StagingDir != "/tmp/override" {
t.Fatalf("err: Overridden staging_dir is not set correctly in the Puppet provisioner!")
}
}