mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 08:51:02 -06:00
f82c192c49
Now that any configuration processing requires schema, we need either a standalone schema or a provider/provisioner configured with one a lot more often in tests. To avoid adding loads of extra boilerplate to the tests, these new helper functions produce objects pre-configured with a schema that should be useful for a number of different cases, and can be customized further for more interesting situations. A lot of our tests can then just use these pre-defined object and attribute names in their fixtures in situations where the canned schemas here are good enough.
30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
package terraform
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestMockResourceProvisioner_impl(t *testing.T) {
|
|
var _ ResourceProvisioner = new(MockResourceProvisioner)
|
|
}
|
|
|
|
// simpleMockProvisioner returns a MockResourceProvisioner that is pre-configured
|
|
// with schema for its own config, with the same content as returned by
|
|
// function simpleTestSchema.
|
|
//
|
|
// For most reasonable uses the returned provisioner must be registered in a
|
|
// componentFactory under the name "test". Use simpleMockComponentFactory
|
|
// to obtain a pre-configured componentFactory containing the result of
|
|
// this function along with simpleMockProvider, both registered as "test".
|
|
//
|
|
// The returned provisioner has no other behaviors by default, but the caller
|
|
// may modify it in order to stub any other required functionality, or modify
|
|
// the default schema stored in the field GetSchemaReturn. Each new call to
|
|
// simpleTestProvisioner produces entirely new instances of all of the nested
|
|
// objects so that callers can mutate without affecting mock objects.
|
|
func simpleMockProvisioner() *MockResourceProvisioner {
|
|
return &MockResourceProvisioner{
|
|
GetConfigSchemaReturnSchema: simpleTestSchema(),
|
|
}
|
|
}
|