Merge pull request #4336 from KohlsTechnology/puppet-masterless-tests

Add more tests for puppet-masterless provisioner
This commit is contained in:
Rickard von Essen 2016-12-29 10:09:35 +01:00 committed by GitHub
commit 526e77c214
1 changed files with 61 additions and 0 deletions

View File

@ -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{