|
|
|
|
@ -42,28 +42,11 @@ func TestLocal(t *testing.T) *Local {
|
|
|
|
|
|
|
|
|
|
// TestLocalProvider modifies the ContextOpts of the *Local parameter to
|
|
|
|
|
// have a provider with the given name.
|
|
|
|
|
func TestLocalProvider(t *testing.T, b *Local, name string, schema *terraform.ProviderSchema) *terraform.MockProvider {
|
|
|
|
|
func TestLocalProvider(t *testing.T, b *Local, name string, schema providers.Schemas) *terraform.MockProvider {
|
|
|
|
|
// Build a mock resource provider for in-memory operations
|
|
|
|
|
p := new(terraform.MockProvider)
|
|
|
|
|
|
|
|
|
|
if schema == nil {
|
|
|
|
|
schema = &terraform.ProviderSchema{} // default schema is empty
|
|
|
|
|
}
|
|
|
|
|
p.GetProviderSchemaResponse = &providers.GetProviderSchemaResponse{
|
|
|
|
|
Provider: providers.Schema{Block: schema.Provider},
|
|
|
|
|
ProviderMeta: providers.Schema{Block: schema.ProviderMeta},
|
|
|
|
|
ResourceTypes: map[string]providers.Schema{},
|
|
|
|
|
DataSources: map[string]providers.Schema{},
|
|
|
|
|
}
|
|
|
|
|
for name, res := range schema.ResourceTypes {
|
|
|
|
|
p.GetProviderSchemaResponse.ResourceTypes[name] = providers.Schema{
|
|
|
|
|
Block: res,
|
|
|
|
|
Version: int64(schema.ResourceTypeSchemaVersions[name]),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for name, dat := range schema.DataSources {
|
|
|
|
|
p.GetProviderSchemaResponse.DataSources[name] = providers.Schema{Block: dat}
|
|
|
|
|
}
|
|
|
|
|
p.GetProviderSchemaResponse = &schema
|
|
|
|
|
|
|
|
|
|
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
|
|
|
|
// this is a destroy plan,
|
|
|
|
|
|