@@ -24,9 +24,10 @@ import (
2424func TestAccSumologicLookupTable_basic (t * testing.T ) {
2525 var lookupTable LookupTable
2626 testName := "SampleLookupTable"
27- testFields := []LookupTableField {{"\" FieldName1\" " , "\" boolean\" " }}
27+ testFieldName := "FieldName1"
28+ testFieldType := "boolean"
2829 testTtl := 100
29- testPrimaryKeys := [] string { " \" FieldName1\" " }
30+ testPrimaryKeys := " FieldName1"
3031 testSizeLimitAction := "StopIncomingMessages"
3132 testDescription := "This is a sample lookup table description."
3233
@@ -36,7 +37,7 @@ func TestAccSumologicLookupTable_basic(t *testing.T) {
3637 CheckDestroy : testAccCheckLookupTableDestroy (lookupTable ),
3738 Steps : []resource.TestStep {
3839 {
39- Config : testAccCheckSumologicLookupTableConfigImported (testName , testFields , testTtl , testPrimaryKeys , testSizeLimitAction , testDescription ),
40+ Config : testAccCheckSumologicLookupTableConfigImported (testName , testFieldName , testFieldType , testTtl , testPrimaryKeys , testSizeLimitAction , testDescription ),
4041 },
4142 {
4243 ResourceName : "sumologic_lookup_table.foo" ,
@@ -50,9 +51,10 @@ func TestAccSumologicLookupTable_basic(t *testing.T) {
5051func TestAccLookupTable_create (t * testing.T ) {
5152 var lookupTable LookupTable
5253 testName := "SampleLookupTable"
53- testFields := []LookupTableField {{"\" FieldName1\" " , "\" boolean\" " }}
54+ testFieldName := "FieldName1"
55+ testFieldType := "boolean"
5456 testTtl := 100
55- testPrimaryKeys := [] string { " \" FieldName1\" " }
57+ testPrimaryKeys := " FieldName1"
5658 testSizeLimitAction := "StopIncomingMessages"
5759 testDescription := "This is a sample lookup table description."
5860 resource .Test (t , resource.TestCase {
@@ -61,16 +63,16 @@ func TestAccLookupTable_create(t *testing.T) {
6163 CheckDestroy : testAccCheckLookupTableDestroy (lookupTable ),
6264 Steps : []resource.TestStep {
6365 {
64- Config : testAccSumologicLookupTable (testName , testFields , testTtl , testPrimaryKeys , testSizeLimitAction , testDescription ),
66+ Config : testAccSumologicLookupTable (testName , testFieldName , testFieldType , testTtl , testPrimaryKeys , testSizeLimitAction , testDescription ),
6567 Check : resource .ComposeTestCheckFunc (
6668 testAccCheckLookupTableExists ("sumologic_lookup_table.test" , & lookupTable , t ),
6769 testAccCheckLookupTableAttributes ("sumologic_lookup_table.test" ),
6870 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "name" , testName ),
6971 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.#" , "1" ),
70- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_name" , testFields [ 0 ]. FieldName ),
71- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_name " , testFields [ 0 ]. FieldType ),
72+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_name" , testFieldName ),
73+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_type " , testFieldType ),
7274 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "ttl" , strconv .Itoa (testTtl )),
73- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "primary_keys.0" , strings . Replace ( testPrimaryKeys [ 0 ], " \" " , "" , 2 ) ),
75+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "primary_keys.0" , testPrimaryKeys ),
7476 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "size_limit_action" , testSizeLimitAction ),
7577 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "description" , testDescription ),
7678 ),
@@ -82,48 +84,46 @@ func TestAccLookupTable_create(t *testing.T) {
8284func TestAccLookupTable_update (t * testing.T ) {
8385 var lookupTable LookupTable
8486 testName := "SampleLookupTable"
85- testFields := []LookupTableField {{"\" FieldName1\" " , "\" boolean\" " }}
87+ testFieldName := "FieldName1"
88+ testFieldType := "boolean"
8689 testTtl := 100
87- testPrimaryKeys := [] string { " \" FieldName1\" " }
90+ testPrimaryKeys := " FieldName1"
8891 testSizeLimitAction := "StopIncomingMessages"
8992 testDescription := "This is a sample lookup table description."
9093
91- testUpdatedName := "SampleLookupTableUpdate"
92- testUpdatedFields := []LookupTableField {{"\" FieldName1\" " , "\" boolean\" " }}
9394 testUpdatedTtl := 101
94- testUpdatedPrimaryKeys := []string {"\" FieldName1\" " }
9595 testUpdatedSizeLimitAction := "DeleteOldData"
96- testUpdatedDescription := "This is a sample lookup table description.Update "
96+ testUpdatedDescription := "This is a sample lookup table description Updated "
9797
9898 resource .Test (t , resource.TestCase {
9999 PreCheck : func () { testAccPreCheck (t ) },
100100 Providers : testAccProviders ,
101101 CheckDestroy : testAccCheckLookupTableDestroy (lookupTable ),
102102 Steps : []resource.TestStep {
103103 {
104- Config : testAccSumologicLookupTable (testName , testFields , testTtl , testPrimaryKeys , testSizeLimitAction , testDescription ),
104+ Config : testAccSumologicLookupTable (testName , testFieldName , testFieldType , testTtl , testPrimaryKeys , testSizeLimitAction , testDescription ),
105105 Check : resource .ComposeTestCheckFunc (
106106 testAccCheckLookupTableExists ("sumologic_lookup_table.test" , & lookupTable , t ),
107107 testAccCheckLookupTableAttributes ("sumologic_lookup_table.test" ),
108108 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "name" , testName ),
109109 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.#" , "1" ),
110- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_name" , testFields [ 0 ]. FieldName ),
111- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_name " , testFields [ 0 ]. FieldType ),
110+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_name" , testFieldName ),
111+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_type " , testFieldType ),
112112 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "ttl" , strconv .Itoa (testTtl )),
113- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "primary_keys.0" , strings . Replace ( testPrimaryKeys [ 0 ], " \" " , "" , 2 ) ),
113+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "primary_keys.0" , testPrimaryKeys ),
114114 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "size_limit_action" , testSizeLimitAction ),
115115 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "description" , testDescription ),
116116 ),
117117 },
118118 {
119- Config : testAccSumologicLookupTableUpdate (testUpdatedName , testUpdatedFields , testUpdatedTtl , testUpdatedPrimaryKeys , testUpdatedSizeLimitAction , testUpdatedDescription ),
119+ Config : testAccSumologicLookupTableUpdate (testName , testFieldName , testFieldType , testUpdatedTtl , testPrimaryKeys , testUpdatedSizeLimitAction , testUpdatedDescription ),
120120 Check : resource .ComposeTestCheckFunc (
121- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "name" , testUpdatedName ),
121+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "name" , testName ),
122122 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.#" , "1" ),
123- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_name" , testUpdatedFields [ 0 ]. FieldName ),
124- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_name " , testUpdatedFields [ 0 ]. FieldType ),
123+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_name" , testFieldName ),
124+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "fields.0.field_type " , testFieldType ),
125125 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "ttl" , strconv .Itoa (testUpdatedTtl )),
126- resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "primary_keys.0" , strings . Replace ( testUpdatedPrimaryKeys [ 0 ], " \" " , "" , 2 ) ),
126+ resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "primary_keys.0" , testPrimaryKeys ),
127127 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "size_limit_action" , testUpdatedSizeLimitAction ),
128128 resource .TestCheckResourceAttr ("sumologic_lookup_table.test" , "description" , testUpdatedDescription ),
129129 ),
@@ -135,18 +135,9 @@ func TestAccLookupTable_update(t *testing.T) {
135135func testAccCheckLookupTableDestroy (lookupTable LookupTable ) resource.TestCheckFunc {
136136 return func (s * terraform.State ) error {
137137 client := testAccProvider .Meta ().(* Client )
138- for _ , r := range s .RootModule ().Resources {
139- fmt .Printf ("##DEBUG## r=%+v\n " , r )
140- fmt .Printf ("##DEBUG## r.Primary=%+v\n " , r .Primary )
141- fmt .Printf ("##DEBUG## r.id=%+v\n " , r .Primary .ID )
142- id := r .Primary .ID
143- u , err := client .GetLookupTable (id )
144- if err != nil {
145- return fmt .Errorf ("Encountered an error: " + err .Error ())
146- }
147- if u != nil {
148- return fmt .Errorf ("LookupTable %s still exists" , id )
149- }
138+ _ , err := client .GetLookupTable (lookupTable .ID )
139+ if err == nil {
140+ return fmt .Errorf ("Lookup Table still exists" )
150141 }
151142 return nil
152143 }
@@ -176,67 +167,65 @@ func testAccCheckLookupTableExists(name string, lookupTable *LookupTable, t *tes
176167 }
177168}
178169
179- func testAccCheckSumologicLookupTableConfigImported (name string , fields [] LookupTableField , ttl int , primaryKeys [] string , sizeLimitAction string , description string ) string {
170+ func testAccCheckSumologicLookupTableConfigImported (name string , testFieldName string , testFieldType string , ttl int , primaryKeys string , sizeLimitAction string , description string ) string {
180171 return fmt .Sprintf (`
181172data "sumologic_personal_folder" "personalFolder" {}
182173resource "sumologic_lookup_table" "foo" {
183174 name = "%s"
184175 fields {
185- field_name = %s
186- field_type = %s
176+ field_name = "%s"
177+ field_type = "%s"
187178 }
188179 ttl = %d
189- primary_keys = %v
180+ primary_keys = ["%s"]
190181 parent_folder_id = "${data.sumologic_personal_folder.personalFolder.id}"
191182 size_limit_action = "%s"
192183 description = "%s"
193184}
194- ` , name , fields [ 0 ]. FieldName , fields [ 0 ]. FieldType , ttl , primaryKeys , sizeLimitAction , description )
185+ ` , name , testFieldName , testFieldType , ttl , primaryKeys , sizeLimitAction , description )
195186}
196187
197- func testAccSumologicLookupTable (name string , fields [] LookupTableField , ttl int , primaryKeys [] string , sizeLimitAction string , description string ) string {
188+ func testAccSumologicLookupTable (name string , testFieldName string , testFieldType string , ttl int , primaryKeys string , sizeLimitAction string , description string ) string {
198189 return fmt .Sprintf (`
199190data "sumologic_personal_folder" "personalFolder" {}
200191resource "sumologic_lookup_table" "test" {
201192 name = "%s"
202193 fields {
203- field_name = %s
204- field_type = %s
194+ field_name = "%s"
195+ field_type = "%s"
205196 }
206197 ttl = %d
207- primary_keys = %v
198+ primary_keys = ["%s"]
208199 parent_folder_id = "${data.sumologic_personal_folder.personalFolder.id}"
209200 size_limit_action = "%s"
210201 description = "%s"
211202}
212- ` , name , fields [ 0 ]. FieldName , fields [ 0 ]. FieldType , ttl , primaryKeys , sizeLimitAction , description )
203+ ` , name , testFieldName , testFieldType , ttl , primaryKeys , sizeLimitAction , description )
213204}
214205
215- func testAccSumologicLookupTableUpdate (name string , fields [] LookupTableField , ttl int , primaryKeys [] string , sizeLimitAction string , description string ) string {
206+ func testAccSumologicLookupTableUpdate (name string , testFieldName string , testFieldType string , ttl int , primaryKeys string , sizeLimitAction string , description string ) string {
216207 return fmt .Sprintf (`
217208data "sumologic_personal_folder" "personalFolder" {}
218209resource "sumologic_lookup_table" "test" {
219210 name = "%s"
220211 fields {
221- field_name = %s
222- field_type = %s
212+ field_name = "%s"
213+ field_type = "%s"
223214 }
224215 ttl = %d
225- primary_keys = %v
216+ primary_keys = ["%s"]
226217 parent_folder_id = "${data.sumologic_personal_folder.personalFolder.id}"
227218 size_limit_action = "%s"
228219 description = "%s"
229220}
230- ` , name , fields [ 0 ]. FieldName , fields [ 0 ]. FieldType , ttl , primaryKeys , sizeLimitAction , description )
221+ ` , name , testFieldName , testFieldType , ttl , primaryKeys , sizeLimitAction , description )
231222}
232223
233224func testAccCheckLookupTableAttributes (name string ) resource.TestCheckFunc {
234225 return func (s * terraform.State ) error {
235226 f := resource .ComposeTestCheckFunc (
236227 resource .TestCheckResourceAttrSet (name , "name" ),
237- resource .TestCheckResourceAttrSet (name , "fields" ),
238228 resource .TestCheckResourceAttrSet (name , "ttl" ),
239- resource .TestCheckResourceAttrSet (name , "primary_keys" ),
240229 resource .TestCheckResourceAttrSet (name , "parent_folder_id" ),
241230 resource .TestCheckResourceAttrSet (name , "size_limit_action" ),
242231 resource .TestCheckResourceAttrSet (name , "description" ),
0 commit comments