From c226b19d08a9232b1416c819d32c6cf3cd2bea59 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Tue, 27 Dec 2016 22:35:13 -0600 Subject: [PATCH] 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 --- provisioner/puppet-server/provisioner_test.go | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/provisioner/puppet-server/provisioner_test.go b/provisioner/puppet-server/provisioner_test.go index 2a4190d7e..46702dfc3 100644 --- a/provisioner/puppet-server/provisioner_test.go +++ b/provisioner/puppet-server/provisioner_test.go @@ -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!") + } +}