Skip to content

Commit 2130664

Browse files
committed
fix tests
1 parent d5f0dc1 commit 2130664

File tree

2 files changed

+86
-64
lines changed

2 files changed

+86
-64
lines changed

internal/provider/resource_tfe_notification_configuration.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var (
3030
_ resource.ResourceWithImportState = &resourceTFENotificationConfiguration{}
3131
)
3232

33-
// NewOrganizationRunTaskResource
33+
// NewNotificationConfigurationResource
3434
func NewNotificationConfigurationResource() resource.Resource {
3535
return &resourceTFENotificationConfiguration{}
3636
}
@@ -216,7 +216,17 @@ func (r *resourceTFENotificationConfiguration) Schema(ctx context.Context, req r
216216
Validators: []validator.Set{
217217
setvalidator.ValueStringsAre(
218218
stringvalidator.OneOf(
219-
string(tfe.NotificationTriggerChangeRequestCreated),
219+
string(tfe.NotificationTriggerCreated),
220+
string(tfe.NotificationTriggerPlanning),
221+
string(tfe.NotificationTriggerNeedsAttention),
222+
string(tfe.NotificationTriggerApplying),
223+
string(tfe.NotificationTriggerCompleted),
224+
string(tfe.NotificationTriggerErrored),
225+
string(tfe.NotificationTriggerAssessmentCheckFailed),
226+
string(tfe.NotificationTriggerAssessmentDrifted),
227+
string(tfe.NotificationTriggerAssessmentFailed),
228+
string(tfe.NotificationTriggerWorkspaceAutoDestroyReminder),
229+
string(tfe.NotificationTriggerWorkspaceAutoDestroyRunResults),
220230
),
221231
),
222232
},

internal/provider/resource_tfe_notification_configuration_test.go

Lines changed: 74 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ func TestAccTFENotificationConfiguration_basic(t *testing.T) {
2121
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
2222

2323
resource.Test(t, resource.TestCase{
24-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
25-
Providers: testAccProviders,
26-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
24+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
25+
ProtoV5ProviderFactories: testAccMuxedProviders,
26+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
2727
Steps: []resource.TestStep{
2828
{
2929
Config: testAccTFENotificationConfiguration_basic(rInt),
@@ -52,9 +52,9 @@ func TestAccTFENotificationConfiguration_emailUserIDs(t *testing.T) {
5252
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
5353

5454
resource.Test(t, resource.TestCase{
55-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
56-
Providers: testAccProviders,
57-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
55+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
56+
ProtoV5ProviderFactories: testAccMuxedProviders,
57+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
5858
Steps: []resource.TestStep{
5959
{
6060
Config: testAccTFENotificationConfiguration_emailUserIDs(rInt),
@@ -83,9 +83,9 @@ func TestAccTFENotificationConfiguration_update(t *testing.T) {
8383
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
8484

8585
resource.Test(t, resource.TestCase{
86-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
87-
Providers: testAccProviders,
88-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
86+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
87+
ProtoV5ProviderFactories: testAccMuxedProviders,
88+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
8989
Steps: []resource.TestStep{
9090
{
9191
Config: testAccTFENotificationConfiguration_basic(rInt),
@@ -136,9 +136,9 @@ func TestAccTFENotificationConfiguration_updateEmailUserIDs(t *testing.T) {
136136
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
137137

138138
resource.Test(t, resource.TestCase{
139-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
140-
Providers: testAccProviders,
141-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
139+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
140+
ProtoV5ProviderFactories: testAccMuxedProviders,
141+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
142142
Steps: []resource.TestStep{
143143
{
144144
Config: testAccTFENotificationConfiguration_emailUserIDs(rInt),
@@ -191,11 +191,11 @@ func TestAccTFENotificationConfiguration_validateSchemaAttributesEmail(t *testin
191191
Steps: []resource.TestStep{
192192
{
193193
Config: testAccTFENotificationConfiguration_emailWithURL(rInt),
194-
ExpectError: regexp.MustCompile(`URL cannot be set with destination type of email`),
194+
ExpectError: regexp.MustCompile(`The attribute 'url' cannot be set when 'destination_type' is 'email'`),
195195
},
196196
{
197197
Config: testAccTFENotificationConfiguration_emailWithToken(rInt),
198-
ExpectError: regexp.MustCompile(`token cannot be set with destination type of email`),
198+
ExpectError: regexp.MustCompile(`The attribute 'token' cannot be set when 'destination_type' is 'email'`),
199199
},
200200
},
201201
})
@@ -210,15 +210,15 @@ func TestAccTFENotificationConfiguration_validateSchemaAttributesGeneric(t *test
210210
Steps: []resource.TestStep{
211211
{
212212
Config: testAccTFENotificationConfiguration_genericWithEmailAddresses(rInt),
213-
ExpectError: regexp.MustCompile(`email addresses cannot be set with destination type of generic`),
213+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_addresses' cannot be set when 'destination_type' is.*'generic'`),
214214
},
215215
{
216216
Config: testAccTFENotificationConfiguration_genericWithEmailUserIDs(rInt),
217-
ExpectError: regexp.MustCompile(`email user IDs cannot be set with destination type of generic`),
217+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_user_ids' cannot be set when 'destination_type' is.*'generic'`),
218218
},
219219
{
220220
Config: testAccTFENotificationConfiguration_genericWithoutURL(rInt),
221-
ExpectError: regexp.MustCompile(`URL is required with destination type of generic`),
221+
ExpectError: regexp.MustCompile(`The attribute 'url' is required when 'destination_type' is 'generic'`),
222222
},
223223
},
224224
})
@@ -233,19 +233,19 @@ func TestAccTFENotificationConfiguration_validateSchemaAttributesSlack(t *testin
233233
Steps: []resource.TestStep{
234234
{
235235
Config: testAccTFENotificationConfiguration_slackWithEmailAddresses(rInt),
236-
ExpectError: regexp.MustCompile(`email addresses cannot be set with destination type of slack`),
236+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_addresses' cannot be set when 'destination_type' is.*'slack'`),
237237
},
238238
{
239239
Config: testAccTFENotificationConfiguration_slackWithEmailUserIDs(rInt),
240-
ExpectError: regexp.MustCompile(`email user IDs cannot be set with destination type of slack`),
240+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_user_ids' cannot be set when 'destination_type' is.*'slack'`),
241241
},
242242
{
243243
Config: testAccTFENotificationConfiguration_slackWithToken(rInt),
244-
ExpectError: regexp.MustCompile(`token cannot be set with destination type of slack`),
244+
ExpectError: regexp.MustCompile(`The attribute 'token' cannot be set when 'destination_type' is 'slack'`),
245245
},
246246
{
247247
Config: testAccTFENotificationConfiguration_slackWithoutURL(rInt),
248-
ExpectError: regexp.MustCompile(`URL is required with destination type of slack`),
248+
ExpectError: regexp.MustCompile(`The attribute 'url' is required when 'destination_type' is 'slack'`),
249249
},
250250
},
251251
})
@@ -260,19 +260,19 @@ func TestAccTFENotificationConfiguration_validateSchemaAttributesMicrosoftTeams(
260260
Steps: []resource.TestStep{
261261
{
262262
Config: testAccTFENotificationConfiguration_microsoftTeamsWithEmailAddresses(rInt),
263-
ExpectError: regexp.MustCompile(`email addresses cannot be set with destination type of microsoft-teams`),
263+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_addresses' cannot be set when 'destination_type' is.*'microsoft-teams'`),
264264
},
265265
{
266266
Config: testAccTFENotificationConfiguration_microsoftTeamsWithEmailUserIDs(rInt),
267-
ExpectError: regexp.MustCompile(`email user IDs cannot be set with destination type of microsoft-teams`),
267+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_user_ids' cannot be set when 'destination_type' is.*'microsoft-teams'`),
268268
},
269269
{
270270
Config: testAccTFENotificationConfiguration_microsoftTeamsWithToken(rInt),
271-
ExpectError: regexp.MustCompile(`token cannot be set with destination type of microsoft-teams`),
271+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'token' cannot be set when 'destination_type' is.*'microsoft-teams'`),
272272
},
273273
{
274274
Config: testAccTFENotificationConfiguration_microsoftTeamsWithoutURL(rInt),
275-
ExpectError: regexp.MustCompile(`URL is required with destination type of microsoft-teams`),
275+
ExpectError: regexp.MustCompile(`The attribute 'url' is required when 'destination_type' is 'microsoft-teams'`),
276276
},
277277
},
278278
})
@@ -283,9 +283,9 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesEmail(t *
283283
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
284284

285285
resource.Test(t, resource.TestCase{
286-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
287-
Providers: testAccProviders,
288-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
286+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
287+
ProtoV5ProviderFactories: testAccMuxedProviders,
288+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
289289
Steps: []resource.TestStep{
290290
{
291291
Config: testAccTFENotificationConfiguration_emailUserIDs(rInt),
@@ -307,11 +307,14 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesEmail(t *
307307
},
308308
{
309309
Config: testAccTFENotificationConfiguration_emailWithURL(rInt),
310-
ExpectError: regexp.MustCompile(`URL cannot be set with destination type of email`),
310+
ExpectError: regexp.MustCompile(`The attribute 'url' cannot be set when 'destination_type' is 'email'`),
311311
},
312312
{
313313
Config: testAccTFENotificationConfiguration_emailWithToken(rInt),
314-
ExpectError: regexp.MustCompile(`token cannot be set with destination type of email`),
314+
ExpectError: regexp.MustCompile(`The attribute 'token' cannot be set when 'destination_type' is 'email'`),
315+
},
316+
{
317+
Config: testAccTFENotificationConfiguration_emailUserIDs(rInt),
315318
},
316319
},
317320
})
@@ -322,9 +325,9 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesGeneric(t
322325
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
323326

324327
resource.Test(t, resource.TestCase{
325-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
326-
Providers: testAccProviders,
327-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
328+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
329+
ProtoV5ProviderFactories: testAccMuxedProviders,
330+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
328331
Steps: []resource.TestStep{
329332
{
330333
Config: testAccTFENotificationConfiguration_basic(rInt),
@@ -346,15 +349,18 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesGeneric(t
346349
},
347350
{
348351
Config: testAccTFENotificationConfiguration_genericWithEmailAddresses(rInt),
349-
ExpectError: regexp.MustCompile(`email addresses cannot be set with destination type of generic`),
352+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_addresses' cannot be set when 'destination_type' is.*'generic'`),
350353
},
351354
{
352355
Config: testAccTFENotificationConfiguration_genericWithEmailUserIDs(rInt),
353-
ExpectError: regexp.MustCompile(`email user IDs cannot be set with destination type of generic`),
356+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_user_ids' cannot be set when 'destination_type' is.*'generic'`),
354357
},
355358
{
356359
Config: testAccTFENotificationConfiguration_genericWithoutURL(rInt),
357-
ExpectError: regexp.MustCompile(`URL is required with destination type of generic`),
360+
ExpectError: regexp.MustCompile(`The attribute 'url' is required when 'destination_type' is 'generic'`),
361+
},
362+
{
363+
Config: testAccTFENotificationConfiguration_basic(rInt),
358364
},
359365
},
360366
})
@@ -365,9 +371,9 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesSlack(t *
365371
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
366372

367373
resource.Test(t, resource.TestCase{
368-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
369-
Providers: testAccProviders,
370-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
374+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
375+
ProtoV5ProviderFactories: testAccMuxedProviders,
376+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
371377
Steps: []resource.TestStep{
372378
{
373379
Config: testAccTFENotificationConfiguration_slack(rInt),
@@ -389,19 +395,22 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesSlack(t *
389395
},
390396
{
391397
Config: testAccTFENotificationConfiguration_slackWithEmailAddresses(rInt),
392-
ExpectError: regexp.MustCompile(`email addresses cannot be set with destination type of slack`),
398+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_addresses' cannot be set when 'destination_type' is.*'slack'`),
393399
},
394400
{
395401
Config: testAccTFENotificationConfiguration_slackWithEmailUserIDs(rInt),
396-
ExpectError: regexp.MustCompile(`email user IDs cannot be set with destination type of slack`),
402+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_user_ids' cannot be set when 'destination_type' is.*'slack'`),
397403
},
398404
{
399405
Config: testAccTFENotificationConfiguration_slackWithToken(rInt),
400-
ExpectError: regexp.MustCompile(`token cannot be set with destination type of slack`),
406+
ExpectError: regexp.MustCompile(`The attribute 'token' cannot be set when 'destination_type' is 'slack'`),
401407
},
402408
{
403409
Config: testAccTFENotificationConfiguration_slackWithoutURL(rInt),
404-
ExpectError: regexp.MustCompile(`URL is required with destination type of slack`),
410+
ExpectError: regexp.MustCompile(`The attribute 'url' is required when 'destination_type' is 'slack'`),
411+
},
412+
{
413+
Config: testAccTFENotificationConfiguration_slack(rInt),
405414
},
406415
},
407416
})
@@ -412,9 +421,9 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesMicrosoft
412421
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
413422

414423
resource.Test(t, resource.TestCase{
415-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
416-
Providers: testAccProviders,
417-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
424+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
425+
ProtoV5ProviderFactories: testAccMuxedProviders,
426+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
418427
Steps: []resource.TestStep{
419428
{
420429
Config: testAccTFENotificationConfiguration_microsoftTeams(rInt),
@@ -432,19 +441,22 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesMicrosoft
432441
},
433442
{
434443
Config: testAccTFENotificationConfiguration_microsoftTeamsWithEmailAddresses(rInt),
435-
ExpectError: regexp.MustCompile(`email addresses cannot be set with destination type of microsoft-teams`),
444+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_addresses' cannot be set when 'destination_type' is.*'microsoft-teams'`),
436445
},
437446
{
438447
Config: testAccTFENotificationConfiguration_microsoftTeamsWithEmailUserIDs(rInt),
439-
ExpectError: regexp.MustCompile(`email user IDs cannot be set with destination type of microsoft-teams`),
448+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'email_user_ids' cannot be set when 'destination_type' is.*'microsoft-teams'`),
440449
},
441450
{
442451
Config: testAccTFENotificationConfiguration_microsoftTeamsWithToken(rInt),
443-
ExpectError: regexp.MustCompile(`token cannot be set with destination type of microsoft-teams`),
452+
ExpectError: regexp.MustCompile(`(?s).*The attribute 'token' cannot be set when 'destination_type' is.*'microsoft-teams'`),
444453
},
445454
{
446455
Config: testAccTFENotificationConfiguration_microsoftTeamsWithoutURL(rInt),
447-
ExpectError: regexp.MustCompile(`URL is required with destination type of microsoft-teams`),
456+
ExpectError: regexp.MustCompile(`The attribute 'url' is required when 'destination_type' is 'microsoft-teams'`),
457+
},
458+
{
459+
Config: testAccTFENotificationConfiguration_microsoftTeams(rInt),
448460
},
449461
},
450462
})
@@ -455,9 +467,9 @@ func TestAccTFENotificationConfiguration_duplicateTriggers(t *testing.T) {
455467
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
456468

457469
resource.Test(t, resource.TestCase{
458-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
459-
Providers: testAccProviders,
460-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
470+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
471+
ProtoV5ProviderFactories: testAccMuxedProviders,
472+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
461473
Steps: []resource.TestStep{
462474
{
463475
Config: testAccTFENotificationConfiguration_duplicateTriggers(rInt),
@@ -487,9 +499,9 @@ func TestAccTFENotificationConfigurationImport_basic(t *testing.T) {
487499
fmt.Printf("Config for testAccTFENotificationConfigurationImport_basic:\n %s\n", testAccTFENotificationConfiguration_basic(rInt))
488500

489501
resource.Test(t, resource.TestCase{
490-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
491-
Providers: testAccProviders,
492-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
502+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
503+
ProtoV5ProviderFactories: testAccMuxedProviders,
504+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
493505
Steps: []resource.TestStep{
494506
{
495507
Config: testAccTFENotificationConfiguration_update(rInt),
@@ -509,9 +521,9 @@ func TestAccTFENotificationConfigurationImport_emailUserIDs(t *testing.T) {
509521
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
510522

511523
resource.Test(t, resource.TestCase{
512-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
513-
Providers: testAccProviders,
514-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
524+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
525+
ProtoV5ProviderFactories: testAccMuxedProviders,
526+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
515527
Steps: []resource.TestStep{
516528
{
517529
Config: testAccTFENotificationConfiguration_updateEmailUserIDs(rInt),
@@ -531,9 +543,9 @@ func TestAccTFENotificationConfigurationImport_emptyEmailUserIDs(t *testing.T) {
531543
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
532544

533545
resource.Test(t, resource.TestCase{
534-
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
535-
Providers: testAccProviders,
536-
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
546+
PreCheck: func() { preCheckTFENotificationConfiguration(t) },
547+
ProtoV5ProviderFactories: testAccMuxedProviders,
548+
CheckDestroy: testAccCheckTFENotificationConfigurationDestroy,
537549
Steps: []resource.TestStep{
538550
{
539551
Config: testAccTFENotificationConfiguration_emailUserIDs(rInt),

0 commit comments

Comments
 (0)