Skip to content

Commit d539d9f

Browse files
committed
chore(sdk): Serve the provider through a mux server
This is in preparation to migrate to the plugin framework.
1 parent 31df7a7 commit d539d9f

17 files changed

+74
-70
lines changed

cloudamqp/provider_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cloudamqp
22

33
import (
4+
"context"
45
"fmt"
56
"net/http"
67
"net/url"
@@ -9,16 +10,15 @@ import (
910
"testing"
1011

1112
"github.com/cloudamqp/terraform-provider-cloudamqp/cloudamqp/vcr-testing/sanitizer"
13+
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
14+
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
1215
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
13-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1416
"github.com/tidwall/gjson"
1517
"gopkg.in/dnaeon/go-vcr.v3/cassette"
1618
"gopkg.in/dnaeon/go-vcr.v3/recorder"
1719
)
1820

1921
var (
20-
testAccProviderFactory map[string]func() (*schema.Provider, error)
21-
2222
mode = recorder.ModeReplayOnly
2323
)
2424

@@ -155,10 +155,19 @@ func cloudamqpResourceTest(t *testing.T, c resource.TestCase) {
155155
return req.URL.Path == "/login"
156156
})
157157

158-
testAccProviderFactory = map[string]func() (*schema.Provider, error){
159-
"cloudamqp": func() (*schema.Provider, error) { return Provider("1.0", rec.GetDefaultClient()), nil },
158+
c.ProtoV5ProviderFactories = map[string]func() (tfprotov5.ProviderServer, error){
159+
"cloudamqp": func() (tfprotov5.ProviderServer, error) {
160+
ctx := context.Background()
161+
162+
muxServer, err := tf5muxserver.NewMuxServer(ctx, Provider("1.0", rec.GetDefaultClient()).GRPCProvider)
163+
164+
if err != nil {
165+
return nil, err
166+
}
167+
168+
return muxServer.ProviderServer(), nil
169+
},
160170
}
161-
c.ProviderFactories = testAccProviderFactory
162171

163172
resource.Test(t, c)
164173
}

cloudamqp/resource_cloudamqp_alarm_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ func TestAccAlarm_Basic(t *testing.T) {
5656
)
5757

5858
cloudamqpResourceTest(t, resource.TestCase{
59-
PreCheck: func() { testAccPreCheck(t) },
60-
ProviderFactories: testAccProviderFactory,
59+
PreCheck: func() { testAccPreCheck(t) },
6160
Steps: []resource.TestStep{
6261
{
6362
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_aws_eventbridge_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ func TestAccIntegrationAwsEventbridge_Basic(t *testing.T) {
2626
)
2727

2828
cloudamqpResourceTest(t, resource.TestCase{
29-
PreCheck: func() { testAccPreCheck(t) },
30-
ProviderFactories: testAccProviderFactory,
29+
PreCheck: func() { testAccPreCheck(t) },
3130
Steps: []resource.TestStep{
3231
{
3332
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_extra_disk_size_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ func TestAccExtraDiskSize_AWS_Basic(t *testing.T) {
2525
)
2626

2727
cloudamqpResourceTest(t, resource.TestCase{
28-
PreCheck: func() { testAccPreCheck(t) },
29-
ProviderFactories: testAccProviderFactory,
28+
PreCheck: func() { testAccPreCheck(t) },
3029
Steps: []resource.TestStep{
3130
{
3231
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -58,8 +57,7 @@ func TestAccExtraDiskSize_GCE_Basic(t *testing.T) {
5857
)
5958

6059
cloudamqpResourceTest(t, resource.TestCase{
61-
PreCheck: func() { testAccPreCheck(t) },
62-
ProviderFactories: testAccProviderFactory,
60+
PreCheck: func() { testAccPreCheck(t) },
6361
Steps: []resource.TestStep{
6462
{
6563
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -91,8 +89,7 @@ func TestAccExtraDiskSize_Azure_Basic(t *testing.T) {
9189
)
9290

9391
cloudamqpResourceTest(t, resource.TestCase{
94-
PreCheck: func() { testAccPreCheck(t) },
95-
ProviderFactories: testAccProviderFactory,
92+
PreCheck: func() { testAccPreCheck(t) },
9693
Steps: []resource.TestStep{
9794
{
9895
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_instance_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ func TestAccInstance_Basic(t *testing.T) {
3232
)
3333

3434
cloudamqpResourceTest(t, resource.TestCase{
35-
PreCheck: func() { testAccPreCheck(t) },
36-
ProviderFactories: testAccProviderFactory,
35+
PreCheck: func() { testAccPreCheck(t) },
3736
Steps: []resource.TestStep{
3837
{
3938
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -94,8 +93,7 @@ func TestAccInstance_Upgrade(t *testing.T) {
9493
}
9594
)
9695
cloudamqpResourceTest(t, resource.TestCase{
97-
PreCheck: func() { testAccPreCheck(t) },
98-
ProviderFactories: testAccProviderFactory,
96+
PreCheck: func() { testAccPreCheck(t) },
9997
Steps: []resource.TestStep{
10098
{
10199
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -144,8 +142,7 @@ func TestAccInstance_PlanChange(t *testing.T) {
144142
)
145143

146144
cloudamqpResourceTest(t, resource.TestCase{
147-
PreCheck: func() { testAccPreCheck(t) },
148-
ProviderFactories: testAccProviderFactory,
145+
PreCheck: func() { testAccPreCheck(t) },
149146
Steps: []resource.TestStep{
150147
{
151148
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -187,8 +184,7 @@ func TestAccInstance_Downgrade(t *testing.T) {
187184
)
188185

189186
cloudamqpResourceTest(t, resource.TestCase{
190-
PreCheck: func() { testAccPreCheck(t) },
191-
ProviderFactories: testAccProviderFactory,
187+
PreCheck: func() { testAccPreCheck(t) },
192188
Steps: []resource.TestStep{
193189
{
194190
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_integration_log_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ func TestAccIntegrationLog_Basic(t *testing.T) {
5454
)
5555

5656
cloudamqpResourceTest(t, resource.TestCase{
57-
PreCheck: func() { testAccPreCheck(t) },
58-
ProviderFactories: testAccProviderFactory,
57+
PreCheck: func() { testAccPreCheck(t) },
5958
Steps: []resource.TestStep{
6059
{
6160
ExpectNonEmptyPlan: true,

cloudamqp/resource_cloudamqp_integration_metric_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ func TestAccIntegrationMetric_Basic(t *testing.T) {
3939
)
4040

4141
cloudamqpResourceTest(t, resource.TestCase{
42-
PreCheck: func() { testAccPreCheck(t) },
43-
ProviderFactories: testAccProviderFactory,
42+
PreCheck: func() { testAccPreCheck(t) },
4443
Steps: []resource.TestStep{
4544
{
4645
ExpectNonEmptyPlan: true,

cloudamqp/resource_cloudamqp_notification_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ func TestAccNotification_Basic(t *testing.T) {
3333
)
3434

3535
cloudamqpResourceTest(t, resource.TestCase{
36-
PreCheck: func() { testAccPreCheck(t) },
37-
ProviderFactories: testAccProviderFactory,
36+
PreCheck: func() { testAccPreCheck(t) },
3837
Steps: []resource.TestStep{
3938
{
4039
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_plugin_community_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ func TestAccPluginCommunity_Basic(t *testing.T) {
3636
)
3737

3838
cloudamqpResourceTest(t, resource.TestCase{
39-
PreCheck: func() { testAccPreCheck(t) },
40-
ProviderFactories: testAccProviderFactory,
39+
PreCheck: func() { testAccPreCheck(t) },
4140
Steps: []resource.TestStep{
4241
{
4342
Config: configuration.GetTemplatedConfig(t, fileNames, params),

cloudamqp/resource_cloudamqp_plugin_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ func TestAccPlugin_Basic(t *testing.T) {
3636
)
3737

3838
cloudamqpResourceTest(t, resource.TestCase{
39-
PreCheck: func() { testAccPreCheck(t) },
40-
ProviderFactories: testAccProviderFactory,
39+
PreCheck: func() { testAccPreCheck(t) },
4140
Steps: []resource.TestStep{
4241
{
4342
Config: configuration.GetTemplatedConfig(t, fileNames, params),

0 commit comments

Comments
 (0)