Commit 30fadde2 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox: Tests for the defaults [GH-44]

parent 4abd1c22
......@@ -181,6 +181,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
b.config.RawShutdownTimeout = "5m"
}
if b.config.RawSSHWaitTimeout == "" {
b.config.RawSSHWaitTimeout = "20m"
}
b.config.ShutdownTimeout, err = time.ParseDuration(b.config.RawShutdownTimeout)
if err != nil {
errs = append(errs, fmt.Errorf("Failed parsing shutdown_timeout: %s", err))
......@@ -194,10 +198,6 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs = append(errs, errors.New("An ssh_username must be specified."))
}
if b.config.RawSSHWaitTimeout == "" {
b.config.RawSSHWaitTimeout = "20m"
}
b.config.SSHWaitTimeout, err = time.ParseDuration(b.config.RawSSHWaitTimeout)
if err != nil {
errs = append(errs, fmt.Errorf("Failed parsing ssh_wait_timeout: %s", err))
......
......@@ -68,6 +68,10 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
t.Fatalf("err: %s", err)
}
if b.config.RawBootWait != "10s" {
t.Fatalf("bad value: %s", b.config.RawBootWait)
}
// Test with a bad boot_wait
config["boot_wait"] = "this is not good"
err = b.Prepare(config)
......@@ -324,9 +328,20 @@ func TestBuilderPrepare_SSHWaitTimeout(t *testing.T) {
var b Builder
config := testConfig()
// Test a default boot_wait
delete(config, "ssh_wait_timeout")
err := b.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
if b.config.RawSSHWaitTimeout != "20m" {
t.Fatalf("bad value: %s", b.config.RawSSHWaitTimeout)
}
// Test with a bad value
config["ssh_wait_timeout"] = "this is not good"
err := b.Prepare(config)
err = b.Prepare(config)
if err == nil {
t.Fatal("should have error")
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment