|
|
|
|
@ -7,6 +7,8 @@ import (
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var createResult = &testBuilder{}
|
|
|
|
|
|
|
|
|
|
type testBuilderFactory struct {
|
|
|
|
|
createCalled bool
|
|
|
|
|
createName string
|
|
|
|
|
@ -15,7 +17,7 @@ type testBuilderFactory struct {
|
|
|
|
|
func (b *testBuilderFactory) CreateBuilder(name string) packer.Builder {
|
|
|
|
|
b.createCalled = true
|
|
|
|
|
b.createName = name
|
|
|
|
|
return &testBuilder{}
|
|
|
|
|
return createResult
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuilderFactoryRPC(t *testing.T) {
|
|
|
|
|
@ -37,9 +39,13 @@ func TestBuilderFactoryRPC(t *testing.T) {
|
|
|
|
|
// Test Create
|
|
|
|
|
name := "foo"
|
|
|
|
|
bClient := &BuilderFactory{client}
|
|
|
|
|
_ = bClient.CreateBuilder(name)
|
|
|
|
|
builder := bClient.CreateBuilder(name)
|
|
|
|
|
assert.True(b.createCalled, "create should be called")
|
|
|
|
|
assert.Equal(b.createName, "foo", "name should be foo")
|
|
|
|
|
|
|
|
|
|
builder.Prepare(42)
|
|
|
|
|
assert.True(createResult.prepareCalled, "prepare should be called")
|
|
|
|
|
assert.Equal(createResult.prepareConfig, 42, "42 should be config")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuilderFactory_ImplementsBuilderFactory(t *testing.T) {
|
|
|
|
|
|