packer-cn/builder/virtualbox/common/export_config_test.go

52 lines
959 B
Go
Raw Normal View History

2013-12-22 13:40:39 -05:00
package common
import (
"testing"
2020-12-17 16:29:25 -05:00
"github.com/hashicorp/packer-plugin-sdk/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"
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"
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"
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)
}
}
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)
}
}