github.com/amanya/packer@v0.12.1-0.20161117214323-902ac5ab2eb6/builder/virtualbox/common/run_config_test.go (about) 1 package common 2 3 import ( 4 "testing" 5 ) 6 7 func TestRunConfigPrepare_BootWait(t *testing.T) { 8 var c *RunConfig 9 var errs []error 10 11 // Test a default boot_wait 12 c = new(RunConfig) 13 errs = c.Prepare(testConfigTemplate(t)) 14 if len(errs) > 0 { 15 t.Fatalf("should not have error: %s", errs) 16 } 17 18 if c.RawBootWait != "10s" { 19 t.Fatalf("bad value: %s", c.RawBootWait) 20 } 21 22 // Test with a bad boot_wait 23 c = new(RunConfig) 24 c.RawBootWait = "this is not good" 25 errs = c.Prepare(testConfigTemplate(t)) 26 if len(errs) == 0 { 27 t.Fatalf("bad: %#v", errs) 28 } 29 30 // Test with a good one 31 c = new(RunConfig) 32 c.RawBootWait = "5s" 33 errs = c.Prepare(testConfigTemplate(t)) 34 if len(errs) > 0 { 35 t.Fatalf("should not have error: %s", errs) 36 } 37 } 38 39 func TestRunConfigPrepare_VRDPBindAddress(t *testing.T) { 40 var c *RunConfig 41 var errs []error 42 43 // Test a default VRDPBindAddress 44 c = new(RunConfig) 45 errs = c.Prepare(testConfigTemplate(t)) 46 if len(errs) > 0 { 47 t.Fatalf("should not have error: %s", errs) 48 } 49 50 if c.VRDPBindAddress != "127.0.0.1" { 51 t.Fatalf("bad value: %s", c.VRDPBindAddress) 52 } 53 54 // Test with a good one 55 c = new(RunConfig) 56 c.VRDPBindAddress = "192.168.0.1" 57 errs = c.Prepare(testConfigTemplate(t)) 58 if len(errs) > 0 { 59 t.Fatalf("should not have error: %s", errs) 60 } 61 }