Fixed tests

This commit is contained in:
jasminSPC 2016-08-31 14:11:10 +02:00
parent 8f8907ee13
commit d84b3af863
2 changed files with 70 additions and 102 deletions

View File

@ -9,9 +9,9 @@ import (
func testConfig() map[string]interface{} { func testConfig() map[string]interface{} {
return map[string]interface{}{ return map[string]interface{}{
"image": "Ubuntu-16.04", "image": "Ubuntu-16.04",
"pbpassword": "password", "password": "password",
"pbusername": "username", "username": "username",
"servername": "packer", "snapshot_name": "packer",
"type": "profitbricks", "type": "profitbricks",
} }
} }
@ -53,34 +53,4 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
if err == nil { if err == nil {
t.Fatal("should have error") t.Fatal("should have error")
} }
} }
func TestBuilderPrepare_Servername(t *testing.T) {
var b Builder
config := testConfig()
delete(config, "servername")
warnings, err := b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err == nil {
t.Fatalf("should error")
}
expected := "packer"
config["servername"] = expected
b = Builder{}
warnings, err = b.Prepare(config)
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
if b.config.SnapshotName != expected {
t.Errorf("found %s, expected %s", b.config.SnapshotName, expected)
}
}

View File

@ -15,50 +15,50 @@ import (
amazonchrootbuilder "github.com/mitchellh/packer/builder/amazon/chroot" amazonchrootbuilder "github.com/mitchellh/packer/builder/amazon/chroot"
amazonebsbuilder "github.com/mitchellh/packer/builder/amazon/ebs" amazonebsbuilder "github.com/mitchellh/packer/builder/amazon/ebs"
amazonimportpostprocessor "github.com/mitchellh/packer/post-processor/amazon-import"
amazoninstancebuilder "github.com/mitchellh/packer/builder/amazon/instance" amazoninstancebuilder "github.com/mitchellh/packer/builder/amazon/instance"
ansiblelocalprovisioner "github.com/mitchellh/packer/provisioner/ansible-local"
ansibleprovisioner "github.com/mitchellh/packer/provisioner/ansible"
artificepostprocessor "github.com/mitchellh/packer/post-processor/artifice"
atlaspostprocessor "github.com/mitchellh/packer/post-processor/atlas"
azurearmbuilder "github.com/mitchellh/packer/builder/azure/arm" azurearmbuilder "github.com/mitchellh/packer/builder/azure/arm"
checksumpostprocessor "github.com/mitchellh/packer/post-processor/checksum"
chefclientprovisioner "github.com/mitchellh/packer/provisioner/chef-client"
chefsoloprovisioner "github.com/mitchellh/packer/provisioner/chef-solo"
compresspostprocessor "github.com/mitchellh/packer/post-processor/compress"
digitaloceanbuilder "github.com/mitchellh/packer/builder/digitalocean" digitaloceanbuilder "github.com/mitchellh/packer/builder/digitalocean"
dockerbuilder "github.com/mitchellh/packer/builder/docker" dockerbuilder "github.com/mitchellh/packer/builder/docker"
dockerimportpostprocessor "github.com/mitchellh/packer/post-processor/docker-import"
dockerpushpostprocessor "github.com/mitchellh/packer/post-processor/docker-push"
dockersavepostprocessor "github.com/mitchellh/packer/post-processor/docker-save"
dockertagpostprocessor "github.com/mitchellh/packer/post-processor/docker-tag"
filebuilder "github.com/mitchellh/packer/builder/file" filebuilder "github.com/mitchellh/packer/builder/file"
fileprovisioner "github.com/mitchellh/packer/provisioner/file"
googlecomputebuilder "github.com/mitchellh/packer/builder/googlecompute" googlecomputebuilder "github.com/mitchellh/packer/builder/googlecompute"
googlecomputeexportpostprocessor "github.com/mitchellh/packer/post-processor/googlecompute-export"
manifestpostprocessor "github.com/mitchellh/packer/post-processor/manifest"
nullbuilder "github.com/mitchellh/packer/builder/null" nullbuilder "github.com/mitchellh/packer/builder/null"
openstackbuilder "github.com/mitchellh/packer/builder/openstack" openstackbuilder "github.com/mitchellh/packer/builder/openstack"
parallelsisobuilder "github.com/mitchellh/packer/builder/parallels/iso" parallelsisobuilder "github.com/mitchellh/packer/builder/parallels/iso"
parallelspvmbuilder "github.com/mitchellh/packer/builder/parallels/pvm" parallelspvmbuilder "github.com/mitchellh/packer/builder/parallels/pvm"
powershellprovisioner "github.com/mitchellh/packer/provisioner/powershell" profitbricksbuilder "github.com/mitchellh/packer/builder/profitbricks"
puppetmasterlessprovisioner "github.com/mitchellh/packer/provisioner/puppet-masterless"
puppetserverprovisioner "github.com/mitchellh/packer/provisioner/puppet-server"
qemubuilder "github.com/mitchellh/packer/builder/qemu" qemubuilder "github.com/mitchellh/packer/builder/qemu"
saltmasterlessprovisioner "github.com/mitchellh/packer/provisioner/salt-masterless"
shelllocalpostprocessor "github.com/mitchellh/packer/post-processor/shell-local"
shelllocalprovisioner "github.com/mitchellh/packer/provisioner/shell-local"
shellprovisioner "github.com/mitchellh/packer/provisioner/shell"
vagrantcloudpostprocessor "github.com/mitchellh/packer/post-processor/vagrant-cloud"
vagrantpostprocessor "github.com/mitchellh/packer/post-processor/vagrant"
virtualboxisobuilder "github.com/mitchellh/packer/builder/virtualbox/iso" virtualboxisobuilder "github.com/mitchellh/packer/builder/virtualbox/iso"
virtualboxovfbuilder "github.com/mitchellh/packer/builder/virtualbox/ovf" virtualboxovfbuilder "github.com/mitchellh/packer/builder/virtualbox/ovf"
vmwareisobuilder "github.com/mitchellh/packer/builder/vmware/iso" vmwareisobuilder "github.com/mitchellh/packer/builder/vmware/iso"
vmwarevmxbuilder "github.com/mitchellh/packer/builder/vmware/vmx" vmwarevmxbuilder "github.com/mitchellh/packer/builder/vmware/vmx"
amazonimportpostprocessor "github.com/mitchellh/packer/post-processor/amazon-import"
artificepostprocessor "github.com/mitchellh/packer/post-processor/artifice"
atlaspostprocessor "github.com/mitchellh/packer/post-processor/atlas"
checksumpostprocessor "github.com/mitchellh/packer/post-processor/checksum"
compresspostprocessor "github.com/mitchellh/packer/post-processor/compress"
dockerimportpostprocessor "github.com/mitchellh/packer/post-processor/docker-import"
dockerpushpostprocessor "github.com/mitchellh/packer/post-processor/docker-push"
dockersavepostprocessor "github.com/mitchellh/packer/post-processor/docker-save"
dockertagpostprocessor "github.com/mitchellh/packer/post-processor/docker-tag"
googlecomputeexportpostprocessor "github.com/mitchellh/packer/post-processor/googlecompute-export"
manifestpostprocessor "github.com/mitchellh/packer/post-processor/manifest"
shelllocalpostprocessor "github.com/mitchellh/packer/post-processor/shell-local"
vagrantpostprocessor "github.com/mitchellh/packer/post-processor/vagrant"
vagrantcloudpostprocessor "github.com/mitchellh/packer/post-processor/vagrant-cloud"
vspherepostprocessor "github.com/mitchellh/packer/post-processor/vsphere" vspherepostprocessor "github.com/mitchellh/packer/post-processor/vsphere"
ansibleprovisioner "github.com/mitchellh/packer/provisioner/ansible"
ansiblelocalprovisioner "github.com/mitchellh/packer/provisioner/ansible-local"
chefclientprovisioner "github.com/mitchellh/packer/provisioner/chef-client"
chefsoloprovisioner "github.com/mitchellh/packer/provisioner/chef-solo"
fileprovisioner "github.com/mitchellh/packer/provisioner/file"
powershellprovisioner "github.com/mitchellh/packer/provisioner/powershell"
puppetmasterlessprovisioner "github.com/mitchellh/packer/provisioner/puppet-masterless"
puppetserverprovisioner "github.com/mitchellh/packer/provisioner/puppet-server"
saltmasterlessprovisioner "github.com/mitchellh/packer/provisioner/salt-masterless"
shellprovisioner "github.com/mitchellh/packer/provisioner/shell"
shelllocalprovisioner "github.com/mitchellh/packer/provisioner/shell-local"
windowsrestartprovisioner "github.com/mitchellh/packer/provisioner/windows-restart" windowsrestartprovisioner "github.com/mitchellh/packer/provisioner/windows-restart"
windowsshellprovisioner "github.com/mitchellh/packer/provisioner/windows-shell" windowsshellprovisioner "github.com/mitchellh/packer/provisioner/windows-shell"
) )
type PluginCommand struct { type PluginCommand struct {
@ -67,61 +67,59 @@ type PluginCommand struct {
var Builders = map[string]packer.Builder{ var Builders = map[string]packer.Builder{
"amazon-chroot": new(amazonchrootbuilder.Builder), "amazon-chroot": new(amazonchrootbuilder.Builder),
"amazon-ebs": new(amazonebsbuilder.Builder), "amazon-ebs": new(amazonebsbuilder.Builder),
"amazon-instance": new(amazoninstancebuilder.Builder), "amazon-instance": new(amazoninstancebuilder.Builder),
"azure-arm": new(azurearmbuilder.Builder), "azure-arm": new(azurearmbuilder.Builder),
"digitalocean": new(digitaloceanbuilder.Builder), "digitalocean": new(digitaloceanbuilder.Builder),
"docker": new(dockerbuilder.Builder), "docker": new(dockerbuilder.Builder),
"file": new(filebuilder.Builder), "file": new(filebuilder.Builder),
"googlecompute": new(googlecomputebuilder.Builder), "googlecompute": new(googlecomputebuilder.Builder),
"null": new(nullbuilder.Builder), "null": new(nullbuilder.Builder),
"openstack": new(openstackbuilder.Builder), "openstack": new(openstackbuilder.Builder),
"parallels-iso": new(parallelsisobuilder.Builder), "parallels-iso": new(parallelsisobuilder.Builder),
"parallels-pvm": new(parallelspvmbuilder.Builder), "parallels-pvm": new(parallelspvmbuilder.Builder),
"qemu": new(qemubuilder.Builder), "profitbricks": new(profitbricksbuilder.Builder),
"virtualbox-iso": new(virtualboxisobuilder.Builder), "qemu": new(qemubuilder.Builder),
"virtualbox-ovf": new(virtualboxovfbuilder.Builder), "virtualbox-iso": new(virtualboxisobuilder.Builder),
"vmware-iso": new(vmwareisobuilder.Builder), "virtualbox-ovf": new(virtualboxovfbuilder.Builder),
"vmware-vmx": new(vmwarevmxbuilder.Builder), "vmware-iso": new(vmwareisobuilder.Builder),
"vmware-vmx": new(vmwarevmxbuilder.Builder),
} }
var Provisioners = map[string]packer.Provisioner{ var Provisioners = map[string]packer.Provisioner{
"ansible": new(ansibleprovisioner.Provisioner), "ansible": new(ansibleprovisioner.Provisioner),
"ansible-local": new(ansiblelocalprovisioner.Provisioner), "ansible-local": new(ansiblelocalprovisioner.Provisioner),
"chef-client": new(chefclientprovisioner.Provisioner), "chef-client": new(chefclientprovisioner.Provisioner),
"chef-solo": new(chefsoloprovisioner.Provisioner), "chef-solo": new(chefsoloprovisioner.Provisioner),
"file": new(fileprovisioner.Provisioner), "file": new(fileprovisioner.Provisioner),
"powershell": new(powershellprovisioner.Provisioner), "powershell": new(powershellprovisioner.Provisioner),
"puppet-masterless": new(puppetmasterlessprovisioner.Provisioner), "puppet-masterless": new(puppetmasterlessprovisioner.Provisioner),
"puppet-server": new(puppetserverprovisioner.Provisioner), "puppet-server": new(puppetserverprovisioner.Provisioner),
"salt-masterless": new(saltmasterlessprovisioner.Provisioner), "salt-masterless": new(saltmasterlessprovisioner.Provisioner),
"shell": new(shellprovisioner.Provisioner), "shell": new(shellprovisioner.Provisioner),
"shell-local": new(shelllocalprovisioner.Provisioner), "shell-local": new(shelllocalprovisioner.Provisioner),
"windows-restart": new(windowsrestartprovisioner.Provisioner), "windows-restart": new(windowsrestartprovisioner.Provisioner),
"windows-shell": new(windowsshellprovisioner.Provisioner), "windows-shell": new(windowsshellprovisioner.Provisioner),
} }
var PostProcessors = map[string]packer.PostProcessor{ var PostProcessors = map[string]packer.PostProcessor{
"amazon-import": new(amazonimportpostprocessor.PostProcessor), "amazon-import": new(amazonimportpostprocessor.PostProcessor),
"artifice": new(artificepostprocessor.PostProcessor), "artifice": new(artificepostprocessor.PostProcessor),
"atlas": new(atlaspostprocessor.PostProcessor), "atlas": new(atlaspostprocessor.PostProcessor),
"checksum": new(checksumpostprocessor.PostProcessor), "checksum": new(checksumpostprocessor.PostProcessor),
"compress": new(compresspostprocessor.PostProcessor), "compress": new(compresspostprocessor.PostProcessor),
"docker-import": new(dockerimportpostprocessor.PostProcessor), "docker-import": new(dockerimportpostprocessor.PostProcessor),
"docker-push": new(dockerpushpostprocessor.PostProcessor), "docker-push": new(dockerpushpostprocessor.PostProcessor),
"docker-save": new(dockersavepostprocessor.PostProcessor), "docker-save": new(dockersavepostprocessor.PostProcessor),
"docker-tag": new(dockertagpostprocessor.PostProcessor), "docker-tag": new(dockertagpostprocessor.PostProcessor),
"googlecompute-export": new(googlecomputeexportpostprocessor.PostProcessor), "googlecompute-export": new(googlecomputeexportpostprocessor.PostProcessor),
"manifest": new(manifestpostprocessor.PostProcessor), "manifest": new(manifestpostprocessor.PostProcessor),
"shell-local": new(shelllocalpostprocessor.PostProcessor), "shell-local": new(shelllocalpostprocessor.PostProcessor),
"vagrant": new(vagrantpostprocessor.PostProcessor), "vagrant": new(vagrantpostprocessor.PostProcessor),
"vagrant-cloud": new(vagrantcloudpostprocessor.PostProcessor), "vagrant-cloud": new(vagrantcloudpostprocessor.PostProcessor),
"vsphere": new(vspherepostprocessor.PostProcessor), "vsphere": new(vspherepostprocessor.PostProcessor),
} }
var pluginRegexp = regexp.MustCompile("packer-(builder|post-processor|provisioner)-(.+)") var pluginRegexp = regexp.MustCompile("packer-(builder|post-processor|provisioner)-(.+)")
func (c *PluginCommand) Run(args []string) int { func (c *PluginCommand) Run(args []string) int {