Skip to content

Commit 56a5f89

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

22 files changed

+81
-84
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

@@ -167,10 +167,19 @@ func cloudamqpResourceTest(t *testing.T, c resource.TestCase) {
167167
return req.URL.Path == "/login"
168168
})
169169

170-
testAccProviderFactory = map[string]func() (*schema.Provider, error){
171-
"cloudamqp": func() (*schema.Provider, error) { return Provider("1.0", rec.GetDefaultClient()), nil },
170+
c.ProtoV5ProviderFactories = map[string]func() (tfprotov5.ProviderServer, error){
171+
"cloudamqp": func() (tfprotov5.ProviderServer, error) {
172+
ctx := context.Background()
173+
174+
muxServer, err := tf5muxserver.NewMuxServer(ctx, Provider("1.0", rec.GetDefaultClient()).GRPCProvider)
175+
176+
if err != nil {
177+
return nil, err
178+
}
179+
180+
return muxServer.ProviderServer(), nil
181+
},
172182
}
173-
c.ProviderFactories = testAccProviderFactory
174183

175184
resource.Test(t, c)
176185
}

cloudamqp/resource_cloudamqp_alarm_test.go

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

5757
cloudamqpResourceTest(t, resource.TestCase{
58-
PreCheck: func() { testAccPreCheck(t) },
59-
ProviderFactories: testAccProviderFactory,
58+
PreCheck: func() { testAccPreCheck(t) },
6059
Steps: []resource.TestStep{
6160
{
6261
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
@@ -27,8 +27,7 @@ func TestAccIntegrationAwsEventbridge_Basic(t *testing.T) {
2727
)
2828

2929
cloudamqpResourceTest(t, resource.TestCase{
30-
PreCheck: func() { testAccPreCheck(t) },
31-
ProviderFactories: testAccProviderFactory,
30+
PreCheck: func() { testAccPreCheck(t) },
3231
Steps: []resource.TestStep{
3332
{
3433
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
@@ -26,8 +26,7 @@ func TestAccExtraDiskSize_AWS_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),
@@ -60,8 +59,7 @@ func TestAccExtraDiskSize_GCE_Basic(t *testing.T) {
6059
)
6160

6261
cloudamqpResourceTest(t, resource.TestCase{
63-
PreCheck: func() { testAccPreCheck(t) },
64-
ProviderFactories: testAccProviderFactory,
62+
PreCheck: func() { testAccPreCheck(t) },
6563
Steps: []resource.TestStep{
6664
{
6765
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -94,8 +92,7 @@ func TestAccExtraDiskSize_Azure_Basic(t *testing.T) {
9492
)
9593

9694
cloudamqpResourceTest(t, resource.TestCase{
97-
PreCheck: func() { testAccPreCheck(t) },
98-
ProviderFactories: testAccProviderFactory,
95+
PreCheck: func() { testAccPreCheck(t) },
9996
Steps: []resource.TestStep{
10097
{
10198
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
@@ -34,8 +34,7 @@ func TestAccInstance_Basic(t *testing.T) {
3434
)
3535

3636
cloudamqpResourceTest(t, resource.TestCase{
37-
PreCheck: func() { testAccPreCheck(t) },
38-
ProviderFactories: testAccProviderFactory,
37+
PreCheck: func() { testAccPreCheck(t) },
3938
Steps: []resource.TestStep{
4039
{
4140
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -96,8 +95,7 @@ func TestAccInstance_Upgrade(t *testing.T) {
9695
}
9796
)
9897
cloudamqpResourceTest(t, resource.TestCase{
99-
PreCheck: func() { testAccPreCheck(t) },
100-
ProviderFactories: testAccProviderFactory,
98+
PreCheck: func() { testAccPreCheck(t) },
10199
Steps: []resource.TestStep{
102100
{
103101
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -146,8 +144,7 @@ func TestAccInstance_PlanChange(t *testing.T) {
146144
)
147145

148146
cloudamqpResourceTest(t, resource.TestCase{
149-
PreCheck: func() { testAccPreCheck(t) },
150-
ProviderFactories: testAccProviderFactory,
147+
PreCheck: func() { testAccPreCheck(t) },
151148
Steps: []resource.TestStep{
152149
{
153150
Config: configuration.GetTemplatedConfig(t, fileNames, params),
@@ -189,8 +186,7 @@ func TestAccInstance_Downgrade(t *testing.T) {
189186
)
190187

191188
cloudamqpResourceTest(t, resource.TestCase{
192-
PreCheck: func() { testAccPreCheck(t) },
193-
ProviderFactories: testAccProviderFactory,
189+
PreCheck: func() { testAccPreCheck(t) },
194190
Steps: []resource.TestStep{
195191
{
196192
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
@@ -55,8 +55,7 @@ func TestAccIntegrationLog_Basic(t *testing.T) {
5555
)
5656

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

cloudamqp/resource_cloudamqp_integration_metric_test.go

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

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

cloudamqp/resource_cloudamqp_maintenance_window_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ func TestAccMaintenanceWindow_LavinMQ(t *testing.T) {
5353
)
5454

5555
cloudamqpResourceTest(t, resource.TestCase{
56-
PreCheck: func() { testAccPreCheck(t) },
57-
ProviderFactories: testAccProviderFactory,
56+
PreCheck: func() { testAccPreCheck(t) },
5857
Steps: []resource.TestStep{
5958
{
6059
Config: configuration.GetTemplatedConfig(t, fileNamesDayTime, paramsDayTime),
@@ -138,8 +137,7 @@ func TestAccMaintenanceWindow_RabbitMQ(t *testing.T) {
138137
)
139138

140139
cloudamqpResourceTest(t, resource.TestCase{
141-
PreCheck: func() { testAccPreCheck(t) },
142-
ProviderFactories: testAccProviderFactory,
140+
PreCheck: func() { testAccPreCheck(t) },
143141
Steps: []resource.TestStep{
144142
{
145143
Config: configuration.GetTemplatedConfig(t, fileNamesDayTime, paramsDayTime),

cloudamqp/resource_cloudamqp_notification_test.go

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

3737
cloudamqpResourceTest(t, resource.TestCase{
38-
PreCheck: func() { testAccPreCheck(t) },
39-
ProviderFactories: testAccProviderFactory,
38+
PreCheck: func() { testAccPreCheck(t) },
4039
Steps: []resource.TestStep{
4140
{
4241
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
@@ -40,8 +40,7 @@ func TestAccPluginCommunity_Basic(t *testing.T) {
4040
)
4141

4242
cloudamqpResourceTest(t, resource.TestCase{
43-
PreCheck: func() { testAccPreCheck(t) },
44-
ProviderFactories: testAccProviderFactory,
43+
PreCheck: func() { testAccPreCheck(t) },
4544
Steps: []resource.TestStep{
4645
{
4746
Config: configuration.GetTemplatedConfig(t, fileNames, params),

0 commit comments

Comments
 (0)