@@ -2099,32 +2099,7 @@ func TestMetaBackend_configureNewStateStore(t *testing.T) {
20992099 //
21002100 // This imagines a provider called foo that contains
21012101 // a pluggable state store implementation called bar.
2102- mock := & testing_provider.MockProvider {
2103- GetProviderSchemaResponse : & providers.GetProviderSchemaResponse {
2104- Provider : providers.Schema {
2105- Body : & configschema.Block {
2106- Attributes : map [string ]* configschema.Attribute {
2107- "region" : {Type : cty .String , Optional : true },
2108- },
2109- },
2110- },
2111- DataSources : map [string ]providers.Schema {},
2112- ResourceTypes : map [string ]providers.Schema {},
2113- ListResourceTypes : map [string ]providers.Schema {},
2114- StateStores : map [string ]providers.Schema {
2115- "foo_bar" : {
2116- Body : & configschema.Block {
2117- Attributes : map [string ]* configschema.Attribute {
2118- "bar" : {
2119- Type : cty .String ,
2120- Required : true ,
2121- },
2122- },
2123- },
2124- },
2125- },
2126- },
2127- }
2102+ mock := testStateStoreMock (t )
21282103 factory := func () (providers.Interface , error ) {
21292104 return mock , nil
21302105 }
@@ -2214,32 +2189,7 @@ func TestMetaBackend_reconfigureStateStoreChange(t *testing.T) {
22142189 //
22152190 // This imagines a provider called foo that contains
22162191 // a pluggable state store implementation called bar.
2217- mock := & testing_provider.MockProvider {
2218- GetProviderSchemaResponse : & providers.GetProviderSchemaResponse {
2219- Provider : providers.Schema {
2220- Body : & configschema.Block {
2221- Attributes : map [string ]* configschema.Attribute {
2222- "region" : {Type : cty .String , Optional : true },
2223- },
2224- },
2225- },
2226- DataSources : map [string ]providers.Schema {},
2227- ResourceTypes : map [string ]providers.Schema {},
2228- ListResourceTypes : map [string ]providers.Schema {},
2229- StateStores : map [string ]providers.Schema {
2230- "foo_bar" : {
2231- Body : & configschema.Block {
2232- Attributes : map [string ]* configschema.Attribute {
2233- "bar" : {
2234- Type : cty .String ,
2235- Required : true ,
2236- },
2237- },
2238- },
2239- },
2240- },
2241- },
2242- }
2192+ mock := testStateStoreMock (t )
22432193 factory := func () (providers.Interface , error ) {
22442194 return mock , nil
22452195 }
@@ -2285,32 +2235,7 @@ func TestMetaBackend_changeConfiguredStateStore(t *testing.T) {
22852235 //
22862236 // This imagines a provider called foo that contains
22872237 // a pluggable state store implementation called bar.
2288- mock := & testing_provider.MockProvider {
2289- GetProviderSchemaResponse : & providers.GetProviderSchemaResponse {
2290- Provider : providers.Schema {
2291- Body : & configschema.Block {
2292- Attributes : map [string ]* configschema.Attribute {
2293- "region" : {Type : cty .String , Optional : true },
2294- },
2295- },
2296- },
2297- DataSources : map [string ]providers.Schema {},
2298- ResourceTypes : map [string ]providers.Schema {},
2299- ListResourceTypes : map [string ]providers.Schema {},
2300- StateStores : map [string ]providers.Schema {
2301- "foo_bar" : {
2302- Body : & configschema.Block {
2303- Attributes : map [string ]* configschema.Attribute {
2304- "bar" : {
2305- Type : cty .String ,
2306- Required : true ,
2307- },
2308- },
2309- },
2310- },
2311- },
2312- },
2313- }
2238+ mock := testStateStoreMock (t )
23142239 factory := func () (providers.Interface , error ) {
23152240 return mock , nil
23162241 }
@@ -2353,32 +2278,7 @@ func TestMetaBackend_configuredBackendToStateStore(t *testing.T) {
23532278 //
23542279 // This imagines a provider called foo that contains
23552280 // a pluggable state store implementation called bar.
2356- mock := & testing_provider.MockProvider {
2357- GetProviderSchemaResponse : & providers.GetProviderSchemaResponse {
2358- Provider : providers.Schema {
2359- Body : & configschema.Block {
2360- Attributes : map [string ]* configschema.Attribute {
2361- "region" : {Type : cty .String , Optional : true },
2362- },
2363- },
2364- },
2365- DataSources : map [string ]providers.Schema {},
2366- ResourceTypes : map [string ]providers.Schema {},
2367- ListResourceTypes : map [string ]providers.Schema {},
2368- StateStores : map [string ]providers.Schema {
2369- "foo_bar" : {
2370- Body : & configschema.Block {
2371- Attributes : map [string ]* configschema.Attribute {
2372- "bar" : {
2373- Type : cty .String ,
2374- Required : true ,
2375- },
2376- },
2377- },
2378- },
2379- },
2380- },
2381- }
2281+ mock := testStateStoreMock (t )
23822282 factory := func () (providers.Interface , error ) {
23832283 return mock , nil
23842284 }
@@ -2475,32 +2375,7 @@ func TestMetaBackend_configureStateStoreVariableUse(t *testing.T) {
24752375 //
24762376 // This imagines a provider called foo that contains
24772377 // a pluggable state store implementation called bar.
2478- mock := & testing_provider.MockProvider {
2479- GetProviderSchemaResponse : & providers.GetProviderSchemaResponse {
2480- Provider : providers.Schema {
2481- Body : & configschema.Block {
2482- Attributes : map [string ]* configschema.Attribute {
2483- "region" : {Type : cty .String , Optional : true },
2484- },
2485- },
2486- },
2487- DataSources : map [string ]providers.Schema {},
2488- ResourceTypes : map [string ]providers.Schema {},
2489- ListResourceTypes : map [string ]providers.Schema {},
2490- StateStores : map [string ]providers.Schema {
2491- "foo_bar" : {
2492- Body : & configschema.Block {
2493- Attributes : map [string ]* configschema.Attribute {
2494- "bar" : {
2495- Type : cty .String ,
2496- Required : true ,
2497- },
2498- },
2499- },
2500- },
2501- },
2502- },
2503- }
2378+ mock := testStateStoreMock (t )
25042379 factory := func () (providers.Interface , error ) {
25052380 return mock , nil
25062381 }
@@ -2538,3 +2413,35 @@ func testMetaBackend(t *testing.T, args []string) *Meta {
25382413
25392414 return & m
25402415}
2416+
2417+ // testStateStoreMock returns a mock provider that has a state store implementation
2418+ // The provider uses the name "test" and the store inside is "test_store".
2419+ func testStateStoreMock (t * testing.T ) * testing_provider.MockProvider {
2420+ t .Helper ()
2421+ return & testing_provider.MockProvider {
2422+ GetProviderSchemaResponse : & providers.GetProviderSchemaResponse {
2423+ Provider : providers.Schema {
2424+ Body : & configschema.Block {
2425+ Attributes : map [string ]* configschema.Attribute {
2426+ "region" : {Type : cty .String , Optional : true },
2427+ },
2428+ },
2429+ },
2430+ DataSources : map [string ]providers.Schema {},
2431+ ResourceTypes : map [string ]providers.Schema {},
2432+ ListResourceTypes : map [string ]providers.Schema {},
2433+ StateStores : map [string ]providers.Schema {
2434+ "test_store" : {
2435+ Body : & configschema.Block {
2436+ Attributes : map [string ]* configschema.Attribute {
2437+ "value" : {
2438+ Type : cty .String ,
2439+ Required : true ,
2440+ },
2441+ },
2442+ },
2443+ },
2444+ },
2445+ },
2446+ }
2447+ }
0 commit comments