Skip to content

Commit b67ff4a

Browse files
authored
tests: replace all remaining sdk provider factories with framework muxed provider factories (#1669)
* tests: add ctor for framework provider with a default org * tests: add default org muxed factory and save global test client reference * tests: first pass migrating to framework muxed provider factory This commit is intended to only have one change, spread across many files. * tests: introduce muxed provider with default org * tests(resource_tfe_workspace_test): update testAccCheckTFEWorkspaceExists This is the first commit focused on resource_tfe_workspace_test. It removes the dependency on the SDK provider from the testAccCheckTFEWorkspaceExists check. * tests(resource_tfe_workspace_test): update testAccCheckTFEWorkspaceDestroy This is the second commit focused on resource_tfe_workspace_test. It removes the dependency on the SDK provider from the testAccCheckTFEWorkspaceDestroy check. * tests(resource_tfe_workspace_test): migrate remaining tests to use muxed provider factory * tests(resource_tfe_no_code_module_test): remove remaining dependencies on sdk provider * tests: replace remaining uses of sdk provider with global client instance This commit is intended to have the same change spread across many files. * tests(resource_tfe_workspace_settings_test): remove sdk provider reference from testAccCheckTFEWorkspaceSettingsDestroy check This commit is focused on resource_tfe_workspace_settings_test. * tests: clean up remaining sdk test provider refs * tests: ensure global test client is set for all muxed providers * tests: fix org default logic for muxedProvidersWithDefaultOrganization
1 parent e5bbe45 commit b67ff4a

File tree

69 files changed

+1125
-1390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1125
-1390
lines changed

internal/provider/data_source_agent_pool_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ func TestAccTFEAgentPoolDataSource_basic(t *testing.T) {
2828
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
2929

3030
resource.Test(t, resource.TestCase{
31-
PreCheck: func() { testAccPreCheck(t) },
32-
Providers: testAccProviders,
31+
PreCheck: func() { testAccPreCheck(t) },
32+
ProtoV5ProviderFactories: testAccMuxedProviders,
3333
Steps: []resource.TestStep{
3434
{
3535
Config: testAccTFEAgentPoolDataSourceConfig(org.Name, rInt),
@@ -68,8 +68,8 @@ func TestAccTFEAgentPoolDataSource_allowed_workspaces(t *testing.T) {
6868
}
6969

7070
resource.Test(t, resource.TestCase{
71-
PreCheck: func() { testAccPreCheck(t) },
72-
Providers: testAccProviders,
71+
PreCheck: func() { testAccPreCheck(t) },
72+
ProtoV5ProviderFactories: testAccMuxedProviders,
7373
Steps: []resource.TestStep{
7474
{
7575
Config: testAccTFEAgentPoolDataSourceAllowedWorkspacesConfig(org.Name, rInt, ws.ID),

internal/provider/data_source_github_app_installation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func testAccTFEGHAInstallationDataSourcePreCheck(t *testing.T) {
1919

2020
func TestAccTFEGHAInstallationDataSource_findByName(t *testing.T) {
2121
resource.Test(t, resource.TestCase{
22-
PreCheck: func() { testAccTFEGHAInstallationDataSourcePreCheck(t) },
23-
Providers: testAccProviders,
22+
PreCheck: func() { testAccTFEGHAInstallationDataSourcePreCheck(t) },
23+
ProtoV5ProviderFactories: testAccMuxedProviders,
2424
Steps: []resource.TestStep{
2525
{
2626
Config: testAccTFEGHAInstallationDataSourceConfig_findByName(envGithubAppInstallationName),

internal/provider/data_source_ip_ranges_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ func TestAccTFEIPRangesDataSource_basic(t *testing.T) {
1515
ipRegex := regexp.MustCompile(`^([\d]{1,3}\.){3}[\d]{1,3}/[\d]{1,3}$`)
1616

1717
resource.Test(t, resource.TestCase{
18-
PreCheck: func() { testAccPreCheck(t) },
19-
Providers: testAccProviders,
18+
PreCheck: func() { testAccPreCheck(t) },
19+
ProtoV5ProviderFactories: testAccMuxedProviders,
2020
Steps: []resource.TestStep{
2121
{
2222
Config: testAccTFEIPRangesDataSourceConfig(),

internal/provider/data_source_oauth_client_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func TestAccTFEOAuthClientDataSource_basic(t *testing.T) {
2424
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
2525

2626
resource.Test(t, resource.TestCase{
27-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
28-
Providers: testAccProviders,
27+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
28+
ProtoV5ProviderFactories: testAccMuxedProviders,
2929
Steps: []resource.TestStep{
3030
{
3131
Config: testAccTFEOAuthClientDataSourceConfig_basic(rInt),
@@ -45,8 +45,8 @@ func TestAccTFEOAuthClientDataSource_basic(t *testing.T) {
4545
func TestAccTFEOAuthClientDataSource_findByID(t *testing.T) {
4646
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
4747
resource.Test(t, resource.TestCase{
48-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
49-
Providers: testAccProviders,
48+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
49+
ProtoV5ProviderFactories: testAccMuxedProviders,
5050
Steps: []resource.TestStep{
5151
{
5252
Config: testAccTFEOAuthClientDataSourceConfig_findByID(rInt),
@@ -75,8 +75,8 @@ func TestAccTFEOAuthClientDataSource_findByID(t *testing.T) {
7575
func TestAccTFEOAuthClientDataSource_findByName(t *testing.T) {
7676
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
7777
resource.Test(t, resource.TestCase{
78-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
79-
Providers: testAccProviders,
78+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
79+
ProtoV5ProviderFactories: testAccMuxedProviders,
8080
Steps: []resource.TestStep{
8181
{
8282
Config: testAccTFEOAuthClientDataSourceConfig_findByName(rInt),
@@ -105,8 +105,8 @@ func TestAccTFEOAuthClientDataSource_findByName(t *testing.T) {
105105
func TestAccTFEOAuthClientDataSource_findByServiceProvider(t *testing.T) {
106106
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
107107
resource.Test(t, resource.TestCase{
108-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
109-
Providers: testAccProviders,
108+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
109+
ProtoV5ProviderFactories: testAccMuxedProviders,
110110
Steps: []resource.TestStep{
111111
{
112112
Config: testAccTFEOAuthClientDataSourceConfig_findByServiceProvider(rInt),
@@ -132,8 +132,8 @@ func TestAccTFEOAuthClientDataSource_findByServiceProvider(t *testing.T) {
132132
func TestAccTFEOAuthClientDataSource_missingParameters(t *testing.T) {
133133
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
134134
resource.Test(t, resource.TestCase{
135-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
136-
Providers: testAccProviders,
135+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
136+
ProtoV5ProviderFactories: testAccMuxedProviders,
137137
Steps: []resource.TestStep{
138138
{
139139
Config: testAccTFEOAuthClientDataSourceConfig_missingParameters(rInt),
@@ -146,8 +146,8 @@ func TestAccTFEOAuthClientDataSource_missingParameters(t *testing.T) {
146146
func TestAccTFEOAuthClientDataSource_missingOrgWithName(t *testing.T) {
147147
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
148148
resource.Test(t, resource.TestCase{
149-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
150-
Providers: testAccProviders,
149+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
150+
ProtoV5ProviderFactories: testAccMuxedProviders,
151151
Steps: []resource.TestStep{
152152
{
153153
Config: testAccTFEOAuthClientDataSourceConfig_missingOrgWithName(rInt),
@@ -160,8 +160,8 @@ func TestAccTFEOAuthClientDataSource_missingOrgWithName(t *testing.T) {
160160
func TestAccTFEOAuthClientDataSource_missingOrgWithServiceProvider(t *testing.T) {
161161
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
162162
resource.Test(t, resource.TestCase{
163-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
164-
Providers: testAccProviders,
163+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
164+
ProtoV5ProviderFactories: testAccMuxedProviders,
165165
Steps: []resource.TestStep{
166166
{
167167
Config: testAccTFEOAuthClientDataSourceConfig_missingOrgWithServiceProvider(rInt),
@@ -174,8 +174,8 @@ func TestAccTFEOAuthClientDataSource_missingOrgWithServiceProvider(t *testing.T)
174174
func TestAccTFEOAuthClientDataSource_sameName(t *testing.T) {
175175
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
176176
resource.Test(t, resource.TestCase{
177-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
178-
Providers: testAccProviders,
177+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
178+
ProtoV5ProviderFactories: testAccMuxedProviders,
179179
Steps: []resource.TestStep{
180180
{
181181
Config: testAccTFEOAuthClientDataSourceConfig_sameName(rInt),
@@ -188,8 +188,8 @@ func TestAccTFEOAuthClientDataSource_sameName(t *testing.T) {
188188
func TestAccTFEOAuthClientDataSource_noName(t *testing.T) {
189189
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
190190
resource.Test(t, resource.TestCase{
191-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
192-
Providers: testAccProviders,
191+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
192+
ProtoV5ProviderFactories: testAccMuxedProviders,
193193
Steps: []resource.TestStep{
194194
{
195195
Config: testAccTFEOAuthClientDataSourceConfig_noName(rInt),
@@ -202,8 +202,8 @@ func TestAccTFEOAuthClientDataSource_noName(t *testing.T) {
202202
func TestAccTFEOAuthClientDataSource_sameServiceProvider(t *testing.T) {
203203
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
204204
resource.Test(t, resource.TestCase{
205-
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
206-
Providers: testAccProviders,
205+
PreCheck: func() { testAccTFEOAuthClientDataSourcePreCheck(t) },
206+
ProtoV5ProviderFactories: testAccMuxedProviders,
207207
Steps: []resource.TestStep{
208208
{
209209
Config: testAccTFEOAuthClientDataSourceConfig_sameServiceProvider(rInt),

internal/provider/data_source_organization_members_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func TestAccTFEOrganizationMembersDataSource_basic(t *testing.T) {
2626
membership := createOrganizationMembership(t, tfeClient, org.Name, options)
2727

2828
resource.Test(t, resource.TestCase{
29-
PreCheck: func() { testAccPreCheck(t) },
30-
Providers: testAccProviders,
29+
PreCheck: func() { testAccPreCheck(t) },
30+
ProtoV5ProviderFactories: testAccMuxedProviders,
3131
Steps: []resource.TestStep{
3232
{
3333
Config: testAccTFEOrganizationMembersDataSourceConfig(org.Name),

internal/provider/data_source_organization_membership_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func TestAccTFEOrganizationMembershipDataSource_basic(t *testing.T) {
1919
orgName := fmt.Sprintf("tst-terraform-%d", rInt)
2020

2121
resource.Test(t, resource.TestCase{
22-
PreCheck: func() { testAccPreCheck(t) },
23-
Providers: testAccProviders,
22+
PreCheck: func() { testAccPreCheck(t) },
23+
ProtoV5ProviderFactories: testAccMuxedProviders,
2424
Steps: []resource.TestStep{
2525
{
2626
Config: testAccTFEOrganizationMembershipDataSourceConfig(rInt),
@@ -67,7 +67,7 @@ func TestAccTFEOrganizationMembershipDataSource_findByName(t *testing.T) {
6767
t.Skip("Please set TFE_USER1 to run this test")
6868
}
6969
},
70-
Providers: testAccProviders,
70+
ProtoV5ProviderFactories: testAccMuxedProviders,
7171
Steps: []resource.TestStep{
7272
{
7373
Config: testAccTFEOrganizationMembershipDataSourceSearchUsername(envTFEUser1),
@@ -89,8 +89,8 @@ func TestAccTFEOrganizationMembershipDataSource_missingParams(t *testing.T) {
8989
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
9090

9191
resource.Test(t, resource.TestCase{
92-
PreCheck: func() { testAccPreCheck(t) },
93-
Providers: testAccProviders,
92+
PreCheck: func() { testAccPreCheck(t) },
93+
ProtoV5ProviderFactories: testAccMuxedProviders,
9494
Steps: []resource.TestStep{
9595
{
9696
Config: testAccTFEOrganizationMembershipDataSourceMissingParams(rInt),

internal/provider/data_source_organization_tags_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ func TestAccTFEOrganizationTagsDataSource_basic(t *testing.T) {
1717
orgName := fmt.Sprintf("tst-terraform-%d", rInt)
1818

1919
resource.Test(t, resource.TestCase{
20-
PreCheck: func() { testAccPreCheck(t) },
21-
Providers: testAccProviders,
20+
PreCheck: func() { testAccPreCheck(t) },
21+
ProtoV5ProviderFactories: testAccMuxedProviders,
2222
Steps: []resource.TestStep{
2323
{
2424
Config: testAccTFEOrganizationTagsDataSourceConfig(rInt),

internal/provider/data_source_organization_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ func TestAccTFEOrganizationDataSource_basic(t *testing.T) {
2020
orgName := fmt.Sprintf("tst-terraform-foo-%d", rInt)
2121

2222
resource.Test(t, resource.TestCase{
23-
PreCheck: func() { testAccPreCheck(t) },
24-
Providers: testAccProviders,
23+
PreCheck: func() { testAccPreCheck(t) },
24+
ProtoV5ProviderFactories: testAccMuxedProviders,
2525
Steps: []resource.TestStep{
2626
{
2727
Config: testAccTFEOrganizationDataSourceConfig_basic(rInt),
@@ -45,8 +45,8 @@ func TestAccTFEOrganizationDataSource_defaultProject(t *testing.T) {
4545
org := &tfe.Organization{}
4646

4747
resource.Test(t, resource.TestCase{
48-
PreCheck: func() { testAccPreCheck(t) },
49-
Providers: testAccProviders,
48+
PreCheck: func() { testAccPreCheck(t) },
49+
ProtoV5ProviderFactories: testAccMuxedProviders,
5050
Steps: []resource.TestStep{
5151
{
5252
Config: testAccTFEOrganizationDataSourceConfig_basic(rInt),
@@ -67,11 +67,11 @@ func TestAccTFEOrganizationDataSource_defaultProject(t *testing.T) {
6767
// The data source will use the default org name from provider config if omitted.
6868
func TestAccTFEOrganizationDataSource_defaultOrganization(t *testing.T) {
6969
defaultOrgName, _ := setupDefaultOrganization(t)
70-
providers := providerWithDefaultOrganization(defaultOrgName)
70+
providers := muxedProvidersWithDefaultOrganization(defaultOrgName)
7171

7272
resource.Test(t, resource.TestCase{
73-
PreCheck: func() { testAccPreCheck(t) },
74-
Providers: providers,
73+
PreCheck: func() { testAccPreCheck(t) },
74+
ProtoV5ProviderFactories: providers,
7575
Steps: []resource.TestStep{
7676
{
7777
Config: testAccTFEOrganizationDataSourceConfig_noName(),

internal/provider/data_source_organizations_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ func TestAccTFEOrganizationsDataSource_basic(t *testing.T) {
1818
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
1919

2020
resource.Test(t, resource.TestCase{
21-
PreCheck: func() { testAccPreCheck(t) },
22-
Providers: testAccProviders,
21+
PreCheck: func() { testAccPreCheck(t) },
22+
ProtoV5ProviderFactories: testAccMuxedProviders,
2323
Steps: []resource.TestStep{
2424
{
2525
Config: testAccTFEOrganizationsDataSourceConfig_basic_resource(rInt),

internal/provider/data_source_policy_set_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func TestAccTFEPolicySetDataSource_basic(t *testing.T) {
3131
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
3232

3333
resource.Test(t, resource.TestCase{
34-
PreCheck: func() { testAccPreCheck(t) },
35-
Providers: testAccProviders,
34+
PreCheck: func() { testAccPreCheck(t) },
35+
ProtoV5ProviderFactories: testAccMuxedProviders,
3636
Steps: []resource.TestStep{
3737
{
3838
Config: testAccTFEPolicySetDataSourceConfig_basic(org.Name, rInt),
@@ -77,9 +77,9 @@ func TestAccTFEPolicySetDataSource_pinnedPolicyRuntimeVersion(t *testing.T) {
7777
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
7878

7979
resource.Test(t, resource.TestCase{
80-
PreCheck: func() { testAccPreCheck(t) },
81-
CheckDestroy: testAccCheckTFESentinelVersionDestroy,
82-
Providers: testAccProviders,
80+
PreCheck: func() { testAccPreCheck(t) },
81+
CheckDestroy: testAccCheckTFESentinelVersionDestroy,
82+
ProtoV5ProviderFactories: testAccMuxedProviders,
8383
Steps: []resource.TestStep{
8484
{
8585
Config: testAccTFEPolicySetDataSourceConfig_pinnedPolicyRuntimeVersion(org.Name, rInt, KnownSentinelToolVersion),
@@ -126,9 +126,9 @@ func TestAccTFEPolicySetDataSourceOPA_basic(t *testing.T) {
126126
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
127127

128128
resource.Test(t, resource.TestCase{
129-
PreCheck: func() { testAccPreCheck(t) },
130-
CheckDestroy: testAccCheckTFEOPAVersionDestroy,
131-
Providers: testAccProviders,
129+
PreCheck: func() { testAccPreCheck(t) },
130+
CheckDestroy: testAccCheckTFEOPAVersionDestroy,
131+
ProtoV5ProviderFactories: testAccMuxedProviders,
132132
Steps: []resource.TestStep{
133133
{
134134
Config: testAccTFEPolicySetDataSourceConfigOPA_basic(org.Name, rInt, KnownOPAToolVersion),
@@ -191,7 +191,7 @@ func TestAccTFEPolicySetDataSource_vcs(t *testing.T) {
191191
t.Skip("Please set GITHUB_POLIY_SET_PATH to run this test")
192192
}
193193
},
194-
Providers: testAccProviders,
194+
ProtoV5ProviderFactories: testAccMuxedProviders,
195195
Steps: []resource.TestStep{
196196
{
197197
Config: testAccTFEPolicySetDataSourceConfig_vcs(org.Name, rInt),
@@ -230,8 +230,8 @@ func TestAccTFEPolicySetDataSource_notFound(t *testing.T) {
230230
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
231231

232232
resource.Test(t, resource.TestCase{
233-
PreCheck: func() { testAccPreCheck(t) },
234-
Providers: testAccProviders,
233+
PreCheck: func() { testAccPreCheck(t) },
234+
ProtoV5ProviderFactories: testAccMuxedProviders,
235235
Steps: []resource.TestStep{
236236
{
237237
Config: testAccTFEPolicySetDataSourceConfig_notFound(rInt),

0 commit comments

Comments
 (0)