2013-12-22 13:40:39 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-06-14 04:55:10 -04:00
|
|
|
|
|
|
|
"github.com/hashicorp/packer/template/interpolate"
|
2013-12-22 13:40:39 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestExportConfigPrepare_BootWait(t *testing.T) {
|
|
|
|
var c *ExportConfig
|
|
|
|
var errs []error
|
|
|
|
|
|
|
|
// Bad
|
|
|
|
c = new(ExportConfig)
|
2018-03-13 04:02:43 -04:00
|
|
|
c.Format = "illegal"
|
2019-06-14 04:55:10 -04:00
|
|
|
errs = c.Prepare(interpolate.NewContext())
|
2013-12-22 13:40:39 -05:00
|
|
|
if len(errs) == 0 {
|
|
|
|
t.Fatalf("bad: %#v", errs)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Good
|
|
|
|
c = new(ExportConfig)
|
|
|
|
c.Format = "ova"
|
2019-06-14 04:55:10 -04:00
|
|
|
errs = c.Prepare(interpolate.NewContext())
|
2013-12-22 13:40:39 -05:00
|
|
|
if len(errs) > 0 {
|
|
|
|
t.Fatalf("should not have error: %s", errs)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Good
|
|
|
|
c = new(ExportConfig)
|
|
|
|
c.Format = "ovf"
|
2019-06-14 04:55:10 -04:00
|
|
|
errs = c.Prepare(interpolate.NewContext())
|
2013-12-22 13:40:39 -05:00
|
|
|
if len(errs) > 0 {
|
|
|
|
t.Fatalf("should not have error: %s", errs)
|
|
|
|
}
|
|
|
|
}
|
2019-06-19 10:34:14 -04:00
|
|
|
|
|
|
|
func TestExportConfigPrepare_Opts(t *testing.T) {
|
|
|
|
var c *ExportConfig
|
|
|
|
var errs []error
|
|
|
|
|
|
|
|
// Good
|
|
|
|
c = new(ExportConfig)
|
|
|
|
c.ExportOpts = []string{
|
|
|
|
"--options",
|
|
|
|
}
|
|
|
|
errs = c.Prepare(interpolate.NewContext())
|
|
|
|
if len(errs) > 0 {
|
|
|
|
t.Fatalf("should not have error: %s", errs)
|
|
|
|
}
|
|
|
|
}
|