Add more tests for puppet-masterless provisioner
* Add tests for staging_directory config option * Add tests for working_directory config option
This commit is contained in:
parent
456eeb6ac5
commit
a617884a16
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue