@@ -10,6 +10,16 @@ import (
1010)
1111
1212func TestAccSumologicGCPSource_create (t * testing.T ) {
13+ testGCPSourceCreate (t , testAccSumologicGCPSourceConfig )
14+ testGCPSourceCreate (t , testAccSumologicGCPSourceConfigDeprecated )
15+ }
16+
17+ func TestAccSumologicGCPSource_update (t * testing.T ) {
18+ testGCPSourceUpdate (t , testAccSumologicGCPSourceConfig )
19+ testGCPSourceUpdate (t , testAccSumologicGCPSourceConfigDeprecated )
20+ }
21+
22+ func testGCPSourceCreate (t * testing.T , getConfig func (string , string , string , string , string , string ) string ) {
1323 var gcpSource GCPSource
1424 var collector Collector
1525 cName , cDescription , cCategory := getRandomizedParams ()
@@ -21,7 +31,7 @@ func TestAccSumologicGCPSource_create(t *testing.T) {
2131 CheckDestroy : testAccCheckGCPSourceDestroy ,
2232 Steps : []resource.TestStep {
2333 {
24- Config : testAccSumologicGCPSourceConfig (cName , cDescription , cCategory , sName , sDescription , sCategory ),
34+ Config : getConfig (cName , cDescription , cCategory , sName , sDescription , sCategory ),
2535 Check : resource .ComposeTestCheckFunc (
2636 testAccCheckGCPSourceExists (resourceName , & gcpSource ),
2737 testAccCheckGCPSourceValues (& gcpSource , sName , sDescription , sCategory ),
@@ -40,7 +50,7 @@ func TestAccSumologicGCPSource_create(t *testing.T) {
4050 })
4151}
4252
43- func TestAccSumologicGCPSource_update (t * testing.T ) {
53+ func testGCPSourceUpdate (t * testing.T , getConfig func ( string , string , string , string , string , string ) string ) {
4454 var gcpSource GCPSource
4555 cName , cDescription , cCategory := getRandomizedParams ()
4656 sName , sDescription , sCategory := getRandomizedParams ()
@@ -52,7 +62,7 @@ func TestAccSumologicGCPSource_update(t *testing.T) {
5262 CheckDestroy : testAccCheckGCPSourceDestroy ,
5363 Steps : []resource.TestStep {
5464 {
55- Config : testAccSumologicGCPSourceConfig (cName , cDescription , cCategory , sName , sDescription , sCategory ),
65+ Config : getConfig (cName , cDescription , cCategory , sName , sDescription , sCategory ),
5666 Check : resource .ComposeTestCheckFunc (
5767 testAccCheckGCPSourceExists (resourceName , & gcpSource ),
5868 testAccCheckGCPSourceValues (& gcpSource , sName , sDescription , sCategory ),
@@ -66,7 +76,7 @@ func TestAccSumologicGCPSource_update(t *testing.T) {
6676 ),
6777 },
6878 {
69- Config : testAccSumologicGCPSourceConfig (cName , cDescription , cCategory , sNameUpdated , sDescriptionUpdated , sCategoryUpdated ),
79+ Config : getConfig (cName , cDescription , cCategory , sNameUpdated , sDescriptionUpdated , sCategoryUpdated ),
7080 Check : resource .ComposeTestCheckFunc (
7181 testAccCheckGCPSourceExists (resourceName , & gcpSource ),
7282 testAccCheckGCPSourceValues (& gcpSource , sNameUpdated , sDescriptionUpdated , sCategoryUpdated ),
@@ -163,28 +173,35 @@ func testAccCheckGCPSourceValues(gcpSource *GCPSource, name, description, catego
163173 }
164174}
165175
166- func testAccSumologicGCPSourceConfig (cName , cDescription , cCategory , sName , sDescription , sCategory string ) string {
176+ func testGCPSourceTemplate (cName , cDescription , cCategory , sName , sDescription , sCategory , thirdPartyRef string ) string {
167177 return fmt .Sprintf (`
168178resource "sumologic_collector" "test" {
169179 name = "%s"
170180 description = "%s"
171181 category = "%s"
172182}
173-
183+
174184resource "sumologic_gcp_source" "gcp" {
175185 name = "%s"
176186 description = "%s"
177187 message_per_request = false
178188 category = "%s"
179- collector_id = "${sumologic_collector.test.id}"
189+ collector_id = "${sumologic_collector.test.id}"%s
190+ }
191+ ` , cName , cDescription , cCategory , sName , sDescription , sCategory , thirdPartyRef )
192+ }
193+
194+ func testAccSumologicGCPSourceConfig (cName , cDescription , cCategory , sName , sDescription , sCategory string ) string {
195+ return testGCPSourceTemplate (cName , cDescription , cCategory , sName , sDescription , sCategory , "" )
196+ }
197+
198+ func testAccSumologicGCPSourceConfigDeprecated (cName , cDescription , cCategory , sName , sDescription , sCategory string ) string {
199+ deprecatedTPR := `
180200 authentication {
181201 type = "NoAuthentication"
182202 }
183-
184203 path {
185204 type = "NoPathExpression"
186- }
187- }
188-
189- ` , cName , cDescription , cCategory , sName , sDescription , sCategory )
205+ }`
206+ return testGCPSourceTemplate (cName , cDescription , cCategory , sName , sDescription , sCategory , deprecatedTPR )
190207}
0 commit comments