diff --git a/builder/lxc/builder_test.go b/builder/lxc/builder_test.go new file mode 100644 index 000000000..e73cd8b0e --- /dev/null +++ b/builder/lxc/builder_test.go @@ -0,0 +1,56 @@ +package lxc + +import ( + "testing" + "os" + + "github.com/mitchellh/packer/packer" +) + +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) + 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) + 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") + } +} diff --git a/builder/lxc/communicator.go b/builder/lxc/communicator.go index 4d6fab911..7a4133057 100644 --- a/builder/lxc/communicator.go +++ b/builder/lxc/communicator.go @@ -9,8 +9,8 @@ import ( "os" "os/exec" "path/filepath" - "syscall" "strings" + "syscall" ) type LxcAttachCommunicator struct { @@ -105,7 +105,7 @@ func (c *LxcAttachCommunicator) Download(src string, w io.Writer) error { } func (c *LxcAttachCommunicator) DownloadDir(src string, dst string, exclude []string) error { - return fmt.Errorf("DownloadDir is not implemented for lxc") + return fmt.Errorf("DownloadDir is not implemented for lxc") } func (c *LxcAttachCommunicator) Execute(commandString string) (*exec.Cmd, error) { diff --git a/builder/lxc/communicator_test.go b/builder/lxc/communicator_test.go new file mode 100644 index 000000000..b8857df47 --- /dev/null +++ b/builder/lxc/communicator_test.go @@ -0,0 +1,14 @@ +package lxc + +import ( + "github.com/mitchellh/packer/packer" + "testing" +) + +func TestCommunicator_ImplementsCommunicator(t *testing.T) { + var raw interface{} + raw = &LxcAttachCommunicator{} + if _, ok := raw.(packer.Communicator); !ok { + t.Fatalf("Communicator should be a communicator") + } +}