packer-cn/builder/lxc/builder_test.go

57 lines
1.1 KiB
Go
Raw Normal View History

2016-05-25 15:34:36 -04:00
package lxc
import (
"os"
2016-05-25 15:34:51 -04:00
"testing"
2016-05-25 15:34:36 -04:00
2017-09-05 18:23:22 -04:00
"github.com/hashicorp/packer/packer"
2016-05-25 15:34:36 -04:00
)
func testConfig() map[string]interface{} {
return map[string]interface{}{
"config_file": "builder_test.go",
"template_name": "debian",
"template_environment_vars": "SUITE=jessie",
}
}
func TestBuilder_Foo(t *testing.T) {
if os.Getenv("PACKER_ACC") == "" {
t.Skip("This test is only run with PACKER_ACC=1")
}
}
func TestBuilderPrepare_ConfigFile(t *testing.T) {
var b Builder
// Good
config := testConfig()
_, warnings, err := b.Prepare(config)
2016-05-25 15:34:36 -04:00
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
// Bad, missing config file
config = testConfig()
delete(config, "config_file")
b = Builder{}
_, warnings, err = b.Prepare(config)
2016-05-25 15:34:36 -04:00
if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings)
}
if err == nil {
t.Fatalf("should have error")
}
}
func TestBuilder_ImplementsBuilder(t *testing.T) {
var raw interface{}
raw = &Builder{}
if _, ok := raw.(packer.Builder); !ok {
t.Fatalf("Builder should be a builder")
}
}