diff --git a/provisioner/puppet-masterless/provisioner_test.go b/provisioner/puppet-masterless/provisioner_test.go index 46fcbc11f..581919bee 100644 --- a/provisioner/puppet-masterless/provisioner_test.go +++ b/provisioner/puppet-masterless/provisioner_test.go @@ -244,6 +244,67 @@ func TestProvisionerPrepare_extraArguments(t *testing.T) { } } +func TestProvisionerPrepare_stagingDir(t *testing.T) { + config := testConfig() + + delete(config, "staging_directory") + 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-masterless" { + t.Fatalf("err: Default staging_directory is not set in the Puppet provisioner!") + } + + // Make sure default staging directory can be overridden + config["staging_directory"] = "/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_directory is not set correctly in the Puppet provisioner!") + } +} + +func TestProvisionerPrepare_workingDir(t *testing.T) { + config := testConfig() + + delete(config, "working_directory") + p := new(Provisioner) + err := p.Prepare(config) + if err != nil { + t.Fatalf("err: %s", err) + } + + // Make sure default working dir and staging dir are the same + if p.config.WorkingDir != p.config.StagingDir { + t.Fatalf("err: Default working_directory is not set to the same value as default staging_directory in the Puppet provisioner!") + } + + // Make sure the default working directory is correct + if p.config.WorkingDir != "/tmp/packer-puppet-masterless" { + t.Fatalf("err: Default working_directory is not set in the Puppet provisioner!") + } + + // Make sure default working directory can be overridden + config["working_directory"] = "/tmp/override" + p = new(Provisioner) + err = p.Prepare(config) + if err != nil { + t.Fatalf("err: %s", err) + } + + if p.config.WorkingDir != "/tmp/override" { + t.Fatalf("err: Overridden working_directory is not set correctly in the Puppet provisioner!") + } +} + func TestProvisionerProvision_extraArguments(t *testing.T) { config := testConfig() ui := &packer.MachineReadableUi{