builder/virtualbox: Add GuestOSType config

This commit is contained in:
Mitchell Hashimoto 2013-06-11 15:57:20 -07:00
parent 4c18b0ae5b
commit 07cacb6dda
2 changed files with 22 additions and 0 deletions

View File

@ -18,6 +18,7 @@ type Builder struct {
}
type config struct {
GuestOSType string `mapstructure:"guest_os_type"`
OutputDir string `mapstructure:"output_directory"`
}
@ -27,6 +28,10 @@ func (b *Builder) Prepare(raw interface{}) error {
return err
}
if b.config.GuestOSType == "" {
b.config.GuestOSType = "Other"
}
if b.config.OutputDir == "" {
b.config.OutputDir = "virtualbox"
}

View File

@ -16,3 +16,20 @@ func TestBuilder_ImplementsBuilder(t *testing.T) {
t.Error("Builder must implement builder.")
}
}
func TestBuilderPrepare_Defaults(t *testing.T) {
var b Builder
config := testConfig()
err := b.Prepare(config)
if err != nil {
t.Fatalf("should not have error: %s", err)
}
if b.config.GuestOSType != "Other" {
t.Errorf("bad guest OS type: %s", b.config.GuestOSType)
}
if b.config.OutputDir != "virtualbox" {
t.Errorf("bad output dir: %s", b.config.OutputDir)
}
}