Skip to content

Commit 4d339f7

Browse files
fix the issue in basic accp test
1 parent 0817501 commit 4d339f7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

aws/data_source_aws_db_event_categories_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package aws
33
import (
44
"fmt"
55
"reflect"
6+
"regexp"
67
"sort"
78
"strconv"
89
"testing"
@@ -19,14 +20,14 @@ func TestAccAWSDbEventCategories_basic(t *testing.T) {
1920
{
2021
Config: testAccCheckAwsDbEventCategoriesConfig,
2122
Check: resource.ComposeTestCheckFunc(
22-
testAccCheckAwsDbEventCategoriesAttr("data.aws_db_event_categories.example"),
23+
testAccAwsDbEventCategoriesAttrCheck("data.aws_db_event_categories.example"),
2324
),
2425
},
2526
},
2627
})
2728
}
2829

29-
func testAccCheckAwsDbEventCategoriesAttr(n string) resource.TestCheckFunc {
30+
func testAccAwsDbEventCategoriesAttrCheck(n string) resource.TestCheckFunc {
3031
return func(s *terraform.State) error {
3132
rs, ok := s.RootModule().Resources[n]
3233
if !ok {
@@ -82,16 +83,16 @@ func testAccCheckAwsDbEventCategoriesBuild(attrs map[string]string) ([]string, e
8283
if qty < 1 {
8384
return nil, fmt.Errorf("No DB Event Categories found.")
8485
}
85-
eventCategories := make([]string, qty)
86-
for n := range eventCategories {
87-
eventCategory, ok := attrs["event_categories."+strconv.Itoa(n)]
88-
if !ok {
89-
return nil, fmt.Errorf("DB Event Categories list is corrupted.")
86+
87+
var eventCategories []string
88+
for k, v := range attrs {
89+
matched, _ := regexp.MatchString("event_categories.[0-9]+", k)
90+
if matched {
91+
eventCategories = append(eventCategories, v)
9092
}
91-
eventCategories[n] = eventCategory
9293
}
93-
return eventCategories, nil
9494

95+
return eventCategories, nil
9596
}
9697

9798
var testAccCheckAwsDbEventCategoriesConfig = `

0 commit comments

Comments
 (0)