@@ -21,7 +21,7 @@ func TestAccTFENotificationConfiguration_basic(t *testing.T) {
21
21
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
22
22
23
23
resource .Test (t , resource.TestCase {
24
- PreCheck : func () { testAccPreCheck (t ) },
24
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
25
25
Providers : testAccProviders ,
26
26
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
27
27
Steps : []resource.TestStep {
@@ -40,7 +40,7 @@ func TestAccTFENotificationConfiguration_basic(t *testing.T) {
40
40
resource .TestCheckResourceAttr (
41
41
"tfe_notification_configuration.foobar" , "triggers.#" , "0" ),
42
42
resource .TestCheckResourceAttr (
43
- "tfe_notification_configuration.foobar" , "url" , "http://example.com" ),
43
+ "tfe_notification_configuration.foobar" , "url" , runTasksURL () ),
44
44
),
45
45
},
46
46
},
@@ -52,7 +52,7 @@ func TestAccTFENotificationConfiguration_emailUserIDs(t *testing.T) {
52
52
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
53
53
54
54
resource .Test (t , resource.TestCase {
55
- PreCheck : func () { testAccPreCheck (t ) },
55
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
56
56
Providers : testAccProviders ,
57
57
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
58
58
Steps : []resource.TestStep {
@@ -83,7 +83,7 @@ func TestAccTFENotificationConfiguration_update(t *testing.T) {
83
83
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
84
84
85
85
resource .Test (t , resource.TestCase {
86
- PreCheck : func () { testAccPreCheck (t ) },
86
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
87
87
Providers : testAccProviders ,
88
88
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
89
89
Steps : []resource.TestStep {
@@ -102,7 +102,7 @@ func TestAccTFENotificationConfiguration_update(t *testing.T) {
102
102
resource .TestCheckResourceAttr (
103
103
"tfe_notification_configuration.foobar" , "triggers.#" , "0" ),
104
104
resource .TestCheckResourceAttr (
105
- "tfe_notification_configuration.foobar" , "url" , "http://example.com" ),
105
+ "tfe_notification_configuration.foobar" , "url" , runTasksURL () ),
106
106
),
107
107
},
108
108
{
@@ -124,7 +124,7 @@ func TestAccTFENotificationConfiguration_update(t *testing.T) {
124
124
resource .TestCheckResourceAttr (
125
125
"tfe_notification_configuration.foobar" , "triggers.#" , "2" ),
126
126
resource .TestCheckResourceAttr (
127
- "tfe_notification_configuration.foobar" , "url" , "http://example.com/ ?update=true" ),
127
+ "tfe_notification_configuration.foobar" , "url" , fmt . Sprintf ( "%s/ ?update=true", runTasksURL ()) ),
128
128
),
129
129
},
130
130
},
@@ -136,7 +136,7 @@ func TestAccTFENotificationConfiguration_updateEmailUserIDs(t *testing.T) {
136
136
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
137
137
138
138
resource .Test (t , resource.TestCase {
139
- PreCheck : func () { testAccPreCheck (t ) },
139
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
140
140
Providers : testAccProviders ,
141
141
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
142
142
Steps : []resource.TestStep {
@@ -186,7 +186,7 @@ func TestAccTFENotificationConfiguration_validateSchemaAttributesEmail(t *testin
186
186
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
187
187
188
188
resource .Test (t , resource.TestCase {
189
- PreCheck : func () { testAccPreCheck (t ) },
189
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
190
190
Providers : testAccProviders ,
191
191
Steps : []resource.TestStep {
192
192
{
@@ -205,7 +205,7 @@ func TestAccTFENotificationConfiguration_validateSchemaAttributesGeneric(t *test
205
205
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
206
206
207
207
resource .Test (t , resource.TestCase {
208
- PreCheck : func () { testAccPreCheck (t ) },
208
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
209
209
Providers : testAccProviders ,
210
210
Steps : []resource.TestStep {
211
211
{
@@ -228,7 +228,7 @@ func TestAccTFENotificationConfiguration_validateSchemaAttributesSlack(t *testin
228
228
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
229
229
230
230
resource .Test (t , resource.TestCase {
231
- PreCheck : func () { testAccPreCheck (t ) },
231
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
232
232
Providers : testAccProviders ,
233
233
Steps : []resource.TestStep {
234
234
{
@@ -255,7 +255,7 @@ func TestAccTFENotificationConfiguration_validateSchemaAttributesMicrosoftTeams(
255
255
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
256
256
257
257
resource .Test (t , resource.TestCase {
258
- PreCheck : func () { testAccPreCheck (t ) },
258
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
259
259
Providers : testAccProviders ,
260
260
Steps : []resource.TestStep {
261
261
{
@@ -283,7 +283,7 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesEmail(t *
283
283
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
284
284
285
285
resource .Test (t , resource.TestCase {
286
- PreCheck : func () { testAccPreCheck (t ) },
286
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
287
287
Providers : testAccProviders ,
288
288
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
289
289
Steps : []resource.TestStep {
@@ -322,7 +322,7 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesGeneric(t
322
322
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
323
323
324
324
resource .Test (t , resource.TestCase {
325
- PreCheck : func () { testAccPreCheck (t ) },
325
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
326
326
Providers : testAccProviders ,
327
327
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
328
328
Steps : []resource.TestStep {
@@ -341,7 +341,7 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesGeneric(t
341
341
resource .TestCheckResourceAttr (
342
342
"tfe_notification_configuration.foobar" , "triggers.#" , "0" ),
343
343
resource .TestCheckResourceAttr (
344
- "tfe_notification_configuration.foobar" , "url" , "http://example.com" ),
344
+ "tfe_notification_configuration.foobar" , "url" , runTasksURL () ),
345
345
),
346
346
},
347
347
{
@@ -365,7 +365,7 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesSlack(t *
365
365
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
366
366
367
367
resource .Test (t , resource.TestCase {
368
- PreCheck : func () { testAccPreCheck (t ) },
368
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
369
369
Providers : testAccProviders ,
370
370
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
371
371
Steps : []resource.TestStep {
@@ -384,7 +384,7 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesSlack(t *
384
384
resource .TestCheckResourceAttr (
385
385
"tfe_notification_configuration.foobar" , "triggers.#" , "0" ),
386
386
resource .TestCheckResourceAttr (
387
- "tfe_notification_configuration.foobar" , "url" , "http://example.com" ),
387
+ "tfe_notification_configuration.foobar" , "url" , runTasksURL () ),
388
388
),
389
389
},
390
390
{
@@ -412,7 +412,7 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesMicrosoft
412
412
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
413
413
414
414
resource .Test (t , resource.TestCase {
415
- PreCheck : func () { testAccPreCheck (t ) },
415
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
416
416
Providers : testAccProviders ,
417
417
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
418
418
Steps : []resource.TestStep {
@@ -427,7 +427,7 @@ func TestAccTFENotificationConfiguration_updateValidateSchemaAttributesMicrosoft
427
427
resource .TestCheckResourceAttr (
428
428
"tfe_notification_configuration.foobar" , "name" , "notification_msteams" ),
429
429
resource .TestCheckResourceAttr (
430
- "tfe_notification_configuration.foobar" , "url" , "http://example.com" ),
430
+ "tfe_notification_configuration.foobar" , "url" , runTasksURL () ),
431
431
),
432
432
},
433
433
{
@@ -455,7 +455,7 @@ func TestAccTFENotificationConfiguration_duplicateTriggers(t *testing.T) {
455
455
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
456
456
457
457
resource .Test (t , resource.TestCase {
458
- PreCheck : func () { testAccPreCheck (t ) },
458
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
459
459
Providers : testAccProviders ,
460
460
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
461
461
Steps : []resource.TestStep {
@@ -474,7 +474,7 @@ func TestAccTFENotificationConfiguration_duplicateTriggers(t *testing.T) {
474
474
resource .TestCheckResourceAttr (
475
475
"tfe_notification_configuration.foobar" , "triggers.#" , "1" ),
476
476
resource .TestCheckResourceAttr (
477
- "tfe_notification_configuration.foobar" , "url" , "http://example.com" ),
477
+ "tfe_notification_configuration.foobar" , "url" , runTasksURL () ),
478
478
),
479
479
},
480
480
},
@@ -485,7 +485,7 @@ func TestAccTFENotificationConfigurationImport_basic(t *testing.T) {
485
485
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
486
486
487
487
resource .Test (t , resource.TestCase {
488
- PreCheck : func () { testAccPreCheck (t ) },
488
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
489
489
Providers : testAccProviders ,
490
490
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
491
491
Steps : []resource.TestStep {
@@ -507,7 +507,7 @@ func TestAccTFENotificationConfigurationImport_emailUserIDs(t *testing.T) {
507
507
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
508
508
509
509
resource .Test (t , resource.TestCase {
510
- PreCheck : func () { testAccPreCheck (t ) },
510
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
511
511
Providers : testAccProviders ,
512
512
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
513
513
Steps : []resource.TestStep {
@@ -529,7 +529,7 @@ func TestAccTFENotificationConfigurationImport_emptyEmailUserIDs(t *testing.T) {
529
529
rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
530
530
531
531
resource .Test (t , resource.TestCase {
532
- PreCheck : func () { testAccPreCheck (t ) },
532
+ PreCheck : func () { preCheckTFENotificationConfiguration (t ) },
533
533
Providers : testAccProviders ,
534
534
CheckDestroy : testAccCheckTFENotificationConfigurationDestroy ,
535
535
Steps : []resource.TestStep {
@@ -591,7 +591,7 @@ func testAccCheckTFENotificationConfigurationAttributes(notificationConfiguratio
591
591
return fmt .Errorf ("Bad triggers: %v" , notificationConfiguration .Triggers )
592
592
}
593
593
594
- if notificationConfiguration .URL != "http://example.com" {
594
+ if notificationConfiguration .URL != runTasksURL () {
595
595
return fmt .Errorf ("Bad URL: %s" , notificationConfiguration .URL )
596
596
}
597
597
@@ -619,7 +619,7 @@ func testAccCheckTFENotificationConfigurationAttributesUpdate(notificationConfig
619
619
return fmt .Errorf ("Bad triggers: %v" , notificationConfiguration .Triggers )
620
620
}
621
621
622
- if notificationConfiguration .URL != "http://example.com/ ?update=true" {
622
+ if notificationConfiguration .URL != fmt . Sprintf ( "%s/ ?update=true", runTasksURL ()) {
623
623
return fmt .Errorf ("Bad URL: %s" , notificationConfiguration .URL )
624
624
}
625
625
@@ -725,7 +725,7 @@ func testAccCheckTFENotificationConfigurationAttributesMicrosoftTeams(notificati
725
725
return fmt .Errorf ("Bad triggers: %v" , notificationConfiguration .Triggers )
726
726
}
727
727
728
- if notificationConfiguration .URL != "http://example.com" {
728
+ if notificationConfiguration .URL != runTasksURL () {
729
729
return fmt .Errorf ("Bad URL: %s" , notificationConfiguration .URL )
730
730
}
731
731
@@ -753,7 +753,7 @@ func testAccCheckTFENotificationConfigurationAttributesDuplicateTriggers(notific
753
753
return fmt .Errorf ("Bad triggers: %v" , notificationConfiguration .Triggers )
754
754
}
755
755
756
- if notificationConfiguration .URL != "http://example.com" {
756
+ if notificationConfiguration .URL != runTasksURL () {
757
757
return fmt .Errorf ("Bad URL: %s" , notificationConfiguration .URL )
758
758
}
759
759
@@ -797,9 +797,9 @@ resource "tfe_workspace" "foobar" {
797
797
resource "tfe_notification_configuration" "foobar" {
798
798
name = "notification_basic"
799
799
destination_type = "generic"
800
- url = "http://example.com "
800
+ url = "%s "
801
801
workspace_id = tfe_workspace.foobar.id
802
- }` , rInt )
802
+ }` , rInt , runTasksURL () )
803
803
}
804
804
805
805
func testAccTFENotificationConfiguration_emailUserIDs (rInt int ) string {
@@ -841,9 +841,9 @@ resource "tfe_workspace" "foobar" {
841
841
resource "tfe_notification_configuration" "foobar" {
842
842
name = "notification_slack"
843
843
destination_type = "slack"
844
- url = "http://example.com "
844
+ url = "%s "
845
845
workspace_id = tfe_workspace.foobar.id
846
- }` , rInt )
846
+ }` , rInt , runTasksURL () )
847
847
}
848
848
849
849
func testAccTFENotificationConfiguration_microsoftTeams (rInt int ) string {
@@ -861,9 +861,9 @@ resource "tfe_workspace" "foobar" {
861
861
resource "tfe_notification_configuration" "foobar" {
862
862
name = "notification_msteams"
863
863
destination_type = "microsoft-teams"
864
- url = "http://example.com "
864
+ url = "%s "
865
865
workspace_id = tfe_workspace.foobar.id
866
- }` , rInt )
866
+ }` , rInt , runTasksURL () )
867
867
}
868
868
869
869
func testAccTFENotificationConfiguration_update (rInt int ) string {
@@ -884,9 +884,9 @@ resource "tfe_notification_configuration" "foobar" {
884
884
enabled = true
885
885
token = "1234567890_update"
886
886
triggers = ["run:created", "run:needs_attention"]
887
- url = "http://example.com /?update=true"
887
+ url = "%s /?update=true"
888
888
workspace_id = tfe_workspace.foobar.id
889
- }` , rInt )
889
+ }` , rInt , runTasksURL () )
890
890
}
891
891
892
892
func testAccTFENotificationConfiguration_updateEmailUserIDs (rInt int ) string {
@@ -930,9 +930,9 @@ resource "tfe_workspace" "foobar" {
930
930
resource "tfe_notification_configuration" "foobar" {
931
931
name = "notification_email_with_url"
932
932
destination_type = "email"
933
- url = "http://example.com "
933
+ url = "%s "
934
934
workspace_id = tfe_workspace.foobar.id
935
- }` , rInt )
935
+ }` , rInt , runTasksURL () )
936
936
}
937
937
938
938
func testAccTFENotificationConfiguration_emailWithToken (rInt int ) string {
@@ -1080,9 +1080,9 @@ resource "tfe_notification_configuration" "foobar" {
1080
1080
name = "notification_slack_with_token"
1081
1081
destination_type = "slack"
1082
1082
token = "1234567890"
1083
- url = "http://example.com "
1083
+ url = "%s "
1084
1084
workspace_id = tfe_workspace.foobar.id
1085
- }` , rInt )
1085
+ }` , rInt , runTasksURL () )
1086
1086
}
1087
1087
1088
1088
func testAccTFENotificationConfiguration_slackWithoutURL (rInt int ) string {
@@ -1165,9 +1165,9 @@ resource "tfe_notification_configuration" "foobar" {
1165
1165
name = "notification_msteams_with_token"
1166
1166
destination_type = "microsoft-teams"
1167
1167
token = "1234567890"
1168
- url = "http://example.com "
1168
+ url = "%s "
1169
1169
workspace_id = tfe_workspace.foobar.id
1170
- }` , rInt )
1170
+ }` , rInt , runTasksURL () )
1171
1171
}
1172
1172
1173
1173
func testAccTFENotificationConfiguration_microsoftTeamsWithoutURL (rInt int ) string {
@@ -1205,7 +1205,15 @@ resource "tfe_notification_configuration" "foobar" {
1205
1205
name = "notification_duplicate_triggers"
1206
1206
destination_type = "generic"
1207
1207
triggers = ["run:created", "run:created", "run:created"]
1208
- url = "http://example.com "
1208
+ url = "%s "
1209
1209
workspace_id = tfe_workspace.foobar.id
1210
- }` , rInt )
1210
+ }` , rInt , runTasksURL ())
1211
+ }
1212
+
1213
+ func preCheckTFENotificationConfiguration (t * testing.T ) {
1214
+ testAccPreCheck (t )
1215
+
1216
+ if runTasksURL () == "" {
1217
+ t .Skip ("RUN_TASKS_URL must be set for notification configuration acceptance tests" )
1218
+ }
1211
1219
}
0 commit comments