@@ -40,6 +40,7 @@ func TestAccSumologicSCEMatchList_createAndUpdate(t *testing.T) {
4040 Providers : testAccProviders ,
4141 CheckDestroy : testAccCSEMatchListDestroy ,
4242 Steps : []resource.TestStep {
43+ // Creates a match list with 1 match list item
4344 {
4445 Config : testCreateCSEMatchListConfig (nDefaultTtl , nDescription , nName , nTargetColumn , liDescription , liExpiration , liValue , liCount ),
4546 Check : resource .ComposeTestCheckFunc (
@@ -49,6 +50,17 @@ func TestAccSumologicSCEMatchList_createAndUpdate(t *testing.T) {
4950 resource .TestCheckResourceAttrSet (resourceName , "id" ),
5051 ),
5152 },
53+ // Updates the match list and its 1 match list item
54+ {
55+ Config : testCreateCSEMatchListConfig (uDefaultTtl , uDescription , nName , nTargetColumn , liDescription , liExpiration , liValue , liCount ),
56+ Check : resource .ComposeTestCheckFunc (
57+ testCheckCSEMatchListExists (resourceName , & matchList ),
58+ testCheckMatchListValues (& matchList , nDefaultTtl , nDescription , nName , nTargetColumn ),
59+ testCheckMatchListItemsValuesAndCount (resourceName , liDescription , liExpiration , liValue , liCount ),
60+ resource .TestCheckResourceAttrSet (resourceName , "id" ),
61+ ),
62+ },
63+ // Deletes the 1 match list item and adds 3 new ones
5264 {
5365 Config : testCreateCSEMatchListConfig (uDefaultTtl , uDescription , nName , nTargetColumn , uliDescription , uliExpiration , uliValue , uliCount ),
5466 Check : resource .ComposeTestCheckFunc (
@@ -57,6 +69,7 @@ func TestAccSumologicSCEMatchList_createAndUpdate(t *testing.T) {
5769 testCheckMatchListItemsValuesAndCount (resourceName , uliDescription , uliExpiration , uliValue , uliCount ),
5870 ),
5971 },
72+ // Deletes all the match list items
6073 {
6174 Config : testDeleteCSEMatchListItemConfig (uDefaultTtl , uDescription , nName , nTargetColumn ),
6275 Check : resource .ComposeTestCheckFunc (
@@ -154,16 +167,16 @@ func testCheckCSEMatchListExists(n string, matchList *CSEMatchListGet) resource.
154167func testCheckMatchListValues (matchList * CSEMatchListGet , nDefaultTtl int , nDescription string , nName string , nTargetColumn string ) resource.TestCheckFunc {
155168 return func (s * terraform.State ) error {
156169 if matchList .DefaultTtl != nDefaultTtl {
157- return fmt .Errorf ("bad default ttl, expected \" %s \" , got: %#v" , nName , matchList .Name )
170+ return fmt .Errorf ("bad default ttl, expected \" %d \" , got: \" %d \" " , nDefaultTtl , matchList .DefaultTtl )
158171 }
159172 if matchList .Description != nDescription {
160- return fmt .Errorf ("bad description, expected \" %s\" , got: %#v " , nDescription , matchList .Description )
173+ return fmt .Errorf ("bad description, expected \" %s\" , got: \" %s \" " , nDescription , matchList .Description )
161174 }
162175 if matchList .Name != nName {
163- return fmt .Errorf ("bad name, expected \" %s\" , got: %#v " , nName , matchList .Name )
176+ return fmt .Errorf ("bad name, expected \" %s\" , got: \" %s \" " , nName , matchList .Name )
164177 }
165178 if matchList .TargetColumn != nTargetColumn {
166- return fmt .Errorf ("bad target column, expected \" %s\" , got: %#v " , nName , matchList .Name )
179+ return fmt .Errorf ("bad target column, expected \" %s\" , got: \" %s \" " , nName , matchList .Name )
167180 }
168181
169182 return nil
@@ -184,7 +197,7 @@ func testCheckMatchListItemsValuesAndCount(resourceName string, expectedDescript
184197 c := testAccProvider .Meta ().(* Client )
185198 matchListResp , err := c .GetCSEMatchListItemsInMatchList (rs .Primary .ID )
186199 if err != nil {
187- return err
200+ return fmt . Errorf ( "could not get match list items by match list id %s" , rs . Primary . ID )
188201 }
189202
190203 actualCount := len (matchListResp .CSEMatchListItemsGetObjects )
@@ -204,12 +217,13 @@ func testCheckMatchListItemsValuesAndCount(resourceName string, expectedDescript
204217 return fmt .Errorf ("expected match list item description to contain \" %s\" , but found \" %s\" instead" , expectedDescription , item .Meta .Description )
205218 }
206219 if ! strings .Contains (item .Expiration , expectedExpiration ) {
207- return fmt .Errorf ("expected expiration to be \" %s\" , but found \" %s\" instead" , expectedExpiration , item .Expiration )
220+ return fmt .Errorf ("expected expiration to contain \" %s\" , but found \" %s\" instead" , expectedExpiration , item .Expiration )
208221 }
209222 if ! strings .Contains (item .Value , expectedValue ) {
210223 return fmt .Errorf ("expected match list item value to contain \" %s\" , but found \" %s\" instead" , expectedValue , item .Value )
211224 }
212225 }
226+
213227 return nil
214228 }
215229}
0 commit comments