2013-07-29 19:42:35 -04:00
|
|
|
package chroot
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func testConfig() map[string]interface{} {
|
2013-07-30 12:55:17 -04:00
|
|
|
return map[string]interface{}{
|
|
|
|
"source_ami": "foo",
|
|
|
|
}
|
2013-07-29 19:42:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuilder_ImplementsBuilder(t *testing.T) {
|
|
|
|
var raw interface{}
|
|
|
|
raw = &Builder{}
|
|
|
|
if _, ok := raw.(packer.Builder); !ok {
|
|
|
|
t.Fatalf("Builder should be a builder")
|
|
|
|
}
|
|
|
|
}
|
2013-07-30 12:55:17 -04:00
|
|
|
|
2013-07-31 01:29:06 -04:00
|
|
|
func TestBuilderPrepare_ChrootMounts(t *testing.T) {
|
|
|
|
b := &Builder{}
|
|
|
|
config := testConfig()
|
|
|
|
|
|
|
|
config["chroot_mounts"] = nil
|
|
|
|
err := b.Prepare(config)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
config["chroot_mounts"] = [][]string{
|
|
|
|
[]string{"bad"},
|
|
|
|
}
|
|
|
|
err = b.Prepare(config)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("should have error")
|
|
|
|
}
|
|
|
|
}
|
2013-07-30 12:55:17 -04:00
|
|
|
func TestBuilderPrepare_SourceAmi(t *testing.T) {
|
|
|
|
b := &Builder{}
|
|
|
|
config := testConfig()
|
|
|
|
|
|
|
|
config["source_ami"] = ""
|
|
|
|
err := b.Prepare(config)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("should have error")
|
|
|
|
}
|
|
|
|
|
|
|
|
config["source_ami"] = "foo"
|
|
|
|
err = b.Prepare(config)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("err: %s", err)
|
|
|
|
}
|
|
|
|
}
|