@@ -17,7 +17,7 @@ func TestAccSumologicSCEMatchList_createAndUpdate(t *testing.T) {
1717 resourceName := "sumologic_cse_match_list.match_list"
1818
1919 // Create values
20- nName := fmt .Sprintf ("Terraform Test Match List %s" , uuid .New ())
20+ nName := fmt .Sprintf ("Terraform Test Match List Loop %s" , uuid .New ())
2121 nDefaultTtl := 10800
2222 nDescription := "Match List Description"
2323 nTargetColumn := "SrcIp"
@@ -49,7 +49,7 @@ func TestAccSumologicSCEMatchList_createAndUpdate(t *testing.T) {
4949 resource .TestCheckResourceAttrSet (resourceName , "id" ),
5050 ),
5151 },
52- // Updates the match list and its 2 match list items
52+ // Updates the match list description only
5353 {
5454 Config : testCreateCSEMatchListConfig (uDefaultTtl , uDescription , nName , nTargetColumn , liDescription , liExpiration , liValue , liCount ),
5555 Check : resource .ComposeTestCheckFunc (
@@ -79,6 +79,73 @@ func TestAccSumologicSCEMatchList_createAndUpdate(t *testing.T) {
7979 })
8080}
8181
82+ func TestAccSumologicSCEMatchList_createAddRemoveItems (t * testing.T ) {
83+ SkipCseTest (t )
84+
85+ var matchList CSEMatchListGet
86+ resourceName := "sumologic_cse_match_list.match_list"
87+
88+ // Create values
89+ nName := fmt .Sprintf ("Terraform Test Match List %s" , uuid .New ())
90+ nDefaultTtl := 10800
91+ nDescription := "Match List Description"
92+ nTargetColumn := "SrcIp"
93+ liDescription := "Match List Item Description"
94+ liExpiration := "2122-02-27T04:00:00"
95+ liValue := "value"
96+ liCount := 3
97+
98+ unDescription := "Updated Match List Description"
99+ uliDescription := "Updated Match List Item Description"
100+
101+ resource .Test (t , resource.TestCase {
102+ PreCheck : func () { testAccPreCheck (t ) },
103+ Providers : testAccProviders ,
104+ CheckDestroy : testAccCSEMatchListDestroy ,
105+ Steps : []resource.TestStep {
106+ // Creates a match list with 3 match list items
107+ {
108+ Config : testCreateCSEMatchListConfig (nDefaultTtl , nDescription , nName , nTargetColumn , liDescription , liExpiration , liValue , liCount ),
109+ Check : resource .ComposeTestCheckFunc (
110+ testCheckCSEMatchListExists (resourceName , & matchList ),
111+ testCheckMatchListValues (& matchList , nDefaultTtl , nDescription , nName , nTargetColumn ),
112+ testCheckMatchListItemsValuesAndCount (resourceName , liDescription , liExpiration , liValue , liCount ),
113+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
114+ ),
115+ },
116+ { // change match list description only
117+ Config : testCreateCSEMatchListConfig (nDefaultTtl , unDescription , nName , nTargetColumn , liDescription , liExpiration , liValue , liCount ),
118+ Check : resource .ComposeTestCheckFunc (
119+ testCheckCSEMatchListExists (resourceName , & matchList ),
120+ testCheckMatchListValues (& matchList , nDefaultTtl , unDescription , nName , nTargetColumn ),
121+ testCheckMatchListItemsValuesAndCount (resourceName , liDescription , liExpiration , liValue , liCount ),
122+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
123+ ),
124+ },
125+ // Add two match list items
126+ {
127+ Config : testCreateCSEMatchListConfig (nDefaultTtl , unDescription , nName , nTargetColumn , liDescription , liExpiration , liValue , liCount + 2 ),
128+ Check : resource .ComposeTestCheckFunc (
129+ testCheckCSEMatchListExists (resourceName , & matchList ),
130+ testCheckMatchListValues (& matchList , nDefaultTtl , unDescription , nName , nTargetColumn ),
131+ testCheckMatchListItemsValuesAndCount (resourceName , liDescription , liExpiration , liValue , liCount + 2 ),
132+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
133+ ),
134+ },
135+ // Remove couple items, change value in remaining two
136+ {
137+ Config : testCreateCSEMatchListConfig (nDefaultTtl , nDescription , nName , nTargetColumn , uliDescription , liExpiration , liValue , liCount - 1 ),
138+ Check : resource .ComposeTestCheckFunc (
139+ testCheckCSEMatchListExists (resourceName , & matchList ),
140+ testCheckMatchListValues (& matchList , nDefaultTtl , nDescription , nName , nTargetColumn ),
141+ testCheckMatchListItemsValuesAndCount (resourceName , uliDescription , liExpiration , liValue , liCount - 1 ),
142+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
143+ ),
144+ },
145+ },
146+ })
147+ }
148+
82149func testAccCSEMatchListDestroy (s * terraform.State ) error {
83150 client := testAccProvider .Meta ().(* Client )
84151
0 commit comments