packer-cn/builder/amazonebs/builder_test.go

44 lines
1002 B
Go
Raw Normal View History

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)
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")
}