Skip to content

Commit 6ca7806

Browse files
add randomness to fix tests
1 parent 6b1a5ed commit 6ca7806

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

sumologic/resource_sumologic_cse_match_rule_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"regexp"
66
"testing"
77

8+
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
89
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
910
"github.com/hashicorp/terraform-plugin-sdk/terraform"
1011
)
@@ -19,15 +20,15 @@ func TestAccSumologicCSEMatchRule_createAndUpdate(t *testing.T) {
1920
entitySelectorExpression := "srcDevice_ip"
2021
expression := "foo = bar"
2122
isPrototype := false
22-
name := "Test Match Rule"
23+
name := acctest.RandomWithPrefix("Test Match Rule")
2324
nameExpression := "Signal Name"
2425
severityMappingType := "constant"
2526
severityMappingDefault := 5
2627
summaryExpression := "Signal Summary"
2728
tag := "foo"
2829
suppressionWindowSize := 24 * 60 * 60 * 1000
2930

30-
nameUpdated := "Updated Match Rule"
31+
nameUpdated := acctest.RandomWithPrefix("Updated Match Rule")
3132
tagUpdated := "bar"
3233
suppressionWindowSizeUpdated := 25 * 60 * 60 * 1000
3334

@@ -83,7 +84,7 @@ func TestAccSumologicCSEMatchRule_failSuppressionValidation(t *testing.T) {
8384
entitySelectorExpression := "srcDevice_ip"
8485
expression := "foo = bar"
8586
isPrototype := false
86-
name := "Test Match Rule"
87+
name := acctest.RandomWithPrefix("Test Match Rule")
8788
nameExpression := "Signal Name"
8889
severityMappingType := "constant"
8990
severityMappingDefault := 5

sumologic/resource_sumologic_cse_rule_tuning_expression_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66
"testing"
77

8+
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
89
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
910
"github.com/hashicorp/terraform-plugin-sdk/terraform"
1011
"github.com/stretchr/testify/assert"
@@ -14,7 +15,7 @@ func TestAccSumologicSCERuleTuningExpression_create(t *testing.T) {
1415
SkipCseTest(t)
1516

1617
var ruleTuningExpression CSERuleTuningExpression
17-
nName := "New Rule Tuning Name"
18+
nName := acctest.RandomWithPrefix("New Rule Tuning Name")
1819
nDescription := "New Rule Tuning Description"
1920
nExpression := "expression"
2021
nEnabled := true

sumologic/resource_sumologic_extraction_rule_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ import (
1717
"strings"
1818
"testing"
1919

20+
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
2021
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
2122
"github.com/hashicorp/terraform-plugin-sdk/terraform"
2223
)
2324

2425
func TestAccSumologicFieldExtractionRule_basic(t *testing.T) {
2526
var fieldextractionrule FieldExtractionRule
26-
testName := FieldsMap["FieldExtractionRule"]["name"]
27+
testName := FieldsMap["FieldExtractionRule"]["name"+acctest.RandString(8)]
2728
testScope := FieldsMap["FieldExtractionRule"]["scope"]
2829
testParseExpression := FieldsMap["FieldExtractionRule"]["parseExpression"]
2930
testEnabled, _ := strconv.ParseBool(FieldsMap["FieldExtractionRule"]["enabled"])
@@ -47,7 +48,7 @@ func TestAccSumologicFieldExtractionRule_basic(t *testing.T) {
4748

4849
func TestAccSumologicFieldExtractionRule_create(t *testing.T) {
4950
var fieldextractionrule FieldExtractionRule
50-
testName := FieldsMap["FieldExtractionRule"]["name"]
51+
testName := FieldsMap["FieldExtractionRule"]["name"+acctest.RandString(8)]
5152
testScope := FieldsMap["FieldExtractionRule"]["scope"]
5253
testParseExpression := FieldsMap["FieldExtractionRule"]["parseExpression"]
5354
testEnabled, _ := strconv.ParseBool(FieldsMap["FieldExtractionRule"]["enabled"])
@@ -114,12 +115,13 @@ func testAccCheckFieldExtractionRuleExists(name string, fieldextractionrule *Fie
114115

115116
func TestAccSumologicFieldExtractionRule_update(t *testing.T) {
116117
var fieldextractionrule FieldExtractionRule
117-
testName := FieldsMap["FieldExtractionRule"]["name"]
118+
randomSuffix := acctest.RandString(8)
119+
testName := FieldsMap["FieldExtractionRule"]["name"+randomSuffix]
118120
testScope := FieldsMap["FieldExtractionRule"]["scope"]
119121
testParseExpression := FieldsMap["FieldExtractionRule"]["parseExpression"]
120122
testEnabled, _ := strconv.ParseBool(FieldsMap["FieldExtractionRule"]["enabled"])
121123

122-
testUpdatedName := FieldsMap["FieldExtractionRule"]["updatedName"]
124+
testUpdatedName := FieldsMap["FieldExtractionRule"]["updatedName"+randomSuffix]
123125
testUpdatedScope := FieldsMap["FieldExtractionRule"]["updatedScope"]
124126
testUpdatedParseExpression := FieldsMap["FieldExtractionRule"]["updatedParseExpression"]
125127
testUpdatedEnabled, _ := strconv.ParseBool(FieldsMap["FieldExtractionRule"]["updatedEnabled"])

0 commit comments

Comments
 (0)