@@ -95,6 +95,34 @@ func TestAccTFEWorkspaceSettings(t *testing.T) {
95
95
})
96
96
}
97
97
98
+ func TestAccTFEWorkspaceWithSettings (t * testing.T ) {
99
+ tfeClient , err := getClientUsingEnv ()
100
+ if err != nil {
101
+ t .Fatal (err )
102
+ }
103
+
104
+ org , cleanupOrg := createBusinessOrganization (t , tfeClient )
105
+ t .Cleanup (cleanupOrg )
106
+
107
+ resource .Test (t , resource.TestCase {
108
+ PreCheck : func () { testAccPreCheck (t ) },
109
+ ProtoV5ProviderFactories : testAccMuxedProviders ,
110
+ Steps : []resource.TestStep {
111
+ // Start with local execution
112
+ {
113
+ Config : testAccTFEWorkspaceSettingsUnknownIDRemoteState (org .Name ),
114
+ Check : resource .ComposeTestCheckFunc (
115
+ resource .TestCheckResourceAttrSet (
116
+ "tfe_workspace_settings.foobar" , "id" ),
117
+ resource .TestCheckResourceAttrSet (
118
+ "tfe_workspace_settings.foobar" , "workspace_id" ,
119
+ ),
120
+ ),
121
+ },
122
+ },
123
+ })
124
+ }
125
+
98
126
func TestAccTFEWorkspaceSettingsRemoteState (t * testing.T ) {
99
127
tfeClient , err := getClientUsingEnv ()
100
128
if err != nil {
@@ -222,7 +250,7 @@ func testAccCheckTFEWorkspaceSettingsDestroy(s *terraform.State) error {
222
250
return testAccCheckTFEWorkspaceSettingsDestroyProvider (testAccProvider )(s )
223
251
}
224
252
225
- func testAccCheckTFEWorkspaceSettingsDestroyProvider (p * schema.Provider ) func (s * terraform.State ) error {
253
+ func testAccCheckTFEWorkspaceSettingsDestroyProvider (_ * schema.Provider ) func (s * terraform.State ) error {
226
254
return func (s * terraform.State ) error {
227
255
tfeClient , err := getClientUsingEnv ()
228
256
if err != nil {
@@ -256,6 +284,26 @@ func testAccCheckTFEWorkspaceSettingsDestroyProvider(p *schema.Provider) func(s
256
284
}
257
285
}
258
286
287
+ func testAccTFEWorkspaceSettingsUnknownIDRemoteState (orgName string ) string {
288
+ return fmt .Sprintf (`
289
+ resource "tfe_workspace" "foobar1" {
290
+ name = "foobar1"
291
+ organization = "%s"
292
+ }
293
+
294
+ resource "tfe_workspace" "foobar2" {
295
+ name = "foobar2"
296
+ organization = "%s"
297
+ }
298
+
299
+ resource "tfe_workspace_settings" "foobar" {
300
+ workspace_id = tfe_workspace.foobar1.id
301
+ global_remote_state = false
302
+ remote_state_consumer_ids = [tfe_workspace.foobar2.id]
303
+ }
304
+ ` , orgName , orgName )
305
+ }
306
+
259
307
func testAccTFEWorkspaceSettingsRemoteState (workspaceID , workspaceID2 string ) string {
260
308
return fmt .Sprintf (`
261
309
resource "tfe_workspace_settings" "foobar" {
0 commit comments