@@ -2099,32 +2099,7 @@ func TestMetaBackend_configureNewStateStore(t *testing.T) {
2099
2099
//
2100
2100
// This imagines a provider called foo that contains
2101
2101
// 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 )
2128
2103
factory := func () (providers.Interface , error ) {
2129
2104
return mock , nil
2130
2105
}
@@ -2214,32 +2189,7 @@ func TestMetaBackend_reconfigureStateStoreChange(t *testing.T) {
2214
2189
//
2215
2190
// This imagines a provider called foo that contains
2216
2191
// 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 )
2243
2193
factory := func () (providers.Interface , error ) {
2244
2194
return mock , nil
2245
2195
}
@@ -2285,32 +2235,7 @@ func TestMetaBackend_changeConfiguredStateStore(t *testing.T) {
2285
2235
//
2286
2236
// This imagines a provider called foo that contains
2287
2237
// 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 )
2314
2239
factory := func () (providers.Interface , error ) {
2315
2240
return mock , nil
2316
2241
}
@@ -2353,32 +2278,7 @@ func TestMetaBackend_configuredBackendToStateStore(t *testing.T) {
2353
2278
//
2354
2279
// This imagines a provider called foo that contains
2355
2280
// 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 )
2382
2282
factory := func () (providers.Interface , error ) {
2383
2283
return mock , nil
2384
2284
}
@@ -2475,32 +2375,7 @@ func TestMetaBackend_configureStateStoreVariableUse(t *testing.T) {
2475
2375
//
2476
2376
// This imagines a provider called foo that contains
2477
2377
// 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 )
2504
2379
factory := func () (providers.Interface , error ) {
2505
2380
return mock , nil
2506
2381
}
@@ -2538,3 +2413,35 @@ func testMetaBackend(t *testing.T, args []string) *Meta {
2538
2413
2539
2414
return & m
2540
2415
}
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