Skip to content

Commit ea767aa

Browse files
authored
Add comments about use of ResourceStores with TestProviders (#36856)
1 parent 86f333e commit ea767aa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

internal/command/testing/test_provider.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ type TestProvider struct {
105105
Store *ResourceStore
106106
}
107107

108+
// NewProvider creates a new TestProvider for use in tests.
109+
//
110+
// If you provide an empty or nil *ResourceStore argument this is equivalent to the provider
111+
// not having provisioned any remote objects prior to the test's events.
112+
//
113+
// If you provide a *ResourceStore containing values, those cty.Values represent remote objects
114+
// that the provider has 'already' provisioned and can return information about immediately in a test.
108115
func NewProvider(store *ResourceStore) *TestProvider {
109116
if store == nil {
110117
store = &ResourceStore{
@@ -381,6 +388,10 @@ func (provider *TestProvider) CloseEphemeralResource(providers.CloseEphemeralRes
381388

382389
// ResourceStore manages a set of cty.Value resources that can be shared between
383390
// TestProvider providers.
391+
//
392+
// A ResourceStore represents the remote objects that a test provider is managing.
393+
// For example, when the test provider gets a ReadResource request it will search
394+
// the store for a resource with a matching ID. See (*TestProvider).ReadResource.
384395
type ResourceStore struct {
385396
mutex sync.RWMutex
386397

0 commit comments

Comments
 (0)