2013-05-09 01:34:20 -04:00
|
|
|
package amazonebs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"cgl.tideland.biz/asserts"
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuilder_ImplementsBuilder(t *testing.T) {
|
|
|
|
assert := asserts.NewTestingAsserts(t, true)
|
|
|
|
|
|
|
|
var actual packer.Builder
|
|
|
|
assert.Implementor(&Builder{}, &actual, "should be a Builder")
|
|
|
|
}
|
2013-05-09 16:19:38 -04:00
|
|
|
|
|
|
|
func TestBuilder_Prepare_BadType(t *testing.T) {
|
|
|
|
b := &Builder{}
|
2013-05-10 20:01:24 -04:00
|
|
|
c := map[string]interface{}{
|
2013-05-09 16:19:38 -04:00
|
|
|
"access_key": []string{},
|
|
|
|
}
|
|
|
|
|
|
|
|
err := b.Prepare(c)
|
2013-05-20 19:39:43 -04:00
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("prepare should fail")
|
|
|
|
}
|
2013-05-09 16:19:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuilder_Prepare_Good(t *testing.T) {
|
|
|
|
assert := asserts.NewTestingAsserts(t, true)
|
|
|
|
|
|
|
|
b := &Builder{}
|
2013-05-10 20:01:24 -04:00
|
|
|
c := map[string]interface{}{
|
2013-05-09 16:19:38 -04:00
|
|
|
"access_key": "foo",
|
|
|
|
"secret_key": "bar",
|
|
|
|
"source_ami": "123456",
|
|
|
|
}
|
|
|
|
|
|
|
|
err := b.Prepare(c)
|
|
|
|
assert.Nil(err, "should not have an error")
|
|
|
|
assert.Equal(b.config.AccessKey, "foo", "should be valid access key")
|
|
|
|
assert.Equal(b.config.SecretKey, "bar", "should be valid secret key")
|
|
|
|
assert.Equal(b.config.SourceAmi, "123456", "should have source AMI")
|
|
|
|
}
|