Skip to content

Commit ed1ace8

Browse files
author
Dominik Rosiek
committed
Make test on separate source
1 parent 87e22e0 commit ed1ace8

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

sumologic/resource_sumologic_http_source_test.go

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,43 @@ import (
1212

1313
func TestAccSumologicHTTPSource_create(t *testing.T) {
1414
var httpSource HTTPSource
15+
var httpTraceSource HTTPSource
1516
var collector Collector
1617
cName := acctest.RandomWithPrefix("tf-acc-test")
1718
cDescription := acctest.RandomWithPrefix("tf-acc-test")
1819
cCategory := acctest.RandomWithPrefix("tf-acc-test")
1920
sName := acctest.RandomWithPrefix("tf-acc-test")
2021
sDescription := acctest.RandomWithPrefix("tf-acc-test")
2122
sCategory := acctest.RandomWithPrefix("tf-acc-test")
23+
tName := acctest.RandomWithPrefix("tf-acc-test")
24+
tDescription := acctest.RandomWithPrefix("tf-acc-test")
25+
tCategory := acctest.RandomWithPrefix("tf-acc-test")
2226
resource.Test(t, resource.TestCase{
2327
PreCheck: func() { testAccPreCheck(t) },
2428
Providers: testAccProviders,
2529
CheckDestroy: testAccCheckHTTPSourceDestroy,
2630
Steps: []resource.TestStep{
2731
{
28-
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory),
32+
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory),
2933
Check: resource.ComposeTestCheckFunc(
3034
testAccCheckHTTPSourceExists("sumologic_http_source.http", &httpSource),
3135
testAccCheckHTTPSourceValues(&httpSource, sName, sDescription, sCategory),
3236
testAccCheckCollectorExists("sumologic_collector.test", &collector),
3337
testAccCheckCollectorValues(&collector, cName, cDescription, cCategory, "Etc/UTC", ""),
38+
testAccCheckHTTPSourceExists("sumologic_http_source.traces", &httpTraceSource),
39+
testAccCheckHTTPSourceValues(&httpTraceSource, tName, tDescription, tCategory),
3440
resource.TestCheckResourceAttrSet("sumologic_http_source.http", "id"),
3541
resource.TestCheckResourceAttrSet("sumologic_http_source.http", "url"),
3642
resource.TestCheckResourceAttr("sumologic_http_source.http", "name", sName),
3743
resource.TestCheckResourceAttr("sumologic_http_source.http", "description", sDescription),
3844
resource.TestCheckResourceAttr("sumologic_http_source.http", "message_per_request", "false"),
3945
resource.TestCheckResourceAttr("sumologic_http_source.http", "category", sCategory),
46+
resource.TestCheckResourceAttrSet("sumologic_http_source.traces", "id"),
47+
resource.TestCheckResourceAttrSet("sumologic_http_source.traces", "url"),
48+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "name", tName),
49+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "description", tDescription),
50+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "category", tCategory),
51+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "content_type", "Zipkin"),
4052
),
4153
},
4254
},
@@ -45,12 +57,16 @@ func TestAccSumologicHTTPSource_create(t *testing.T) {
4557

4658
func TestAccSumologicHTTPSource_update(t *testing.T) {
4759
var httpSource HTTPSource
60+
var httpTraceSource HTTPSource
4861
cName := acctest.RandomWithPrefix("tf-acc-test")
4962
cDescription := acctest.RandomWithPrefix("tf-acc-test")
5063
cCategory := acctest.RandomWithPrefix("tf-acc-test")
5164
sName := acctest.RandomWithPrefix("tf-acc-test")
5265
sDescription := acctest.RandomWithPrefix("tf-acc-test")
5366
sCategory := acctest.RandomWithPrefix("tf-acc-test")
67+
tName := acctest.RandomWithPrefix("tf-acc-test")
68+
tDescription := acctest.RandomWithPrefix("tf-acc-test")
69+
tCategory := acctest.RandomWithPrefix("tf-acc-test")
5470
sNameUpdated := acctest.RandomWithPrefix("tf-acc-test")
5571
sDescriptionUpdated := acctest.RandomWithPrefix("tf-acc-test")
5672
sCategoryUpdated := acctest.RandomWithPrefix("tf-acc-test")
@@ -60,20 +76,28 @@ func TestAccSumologicHTTPSource_update(t *testing.T) {
6076
CheckDestroy: testAccCheckHTTPSourceDestroy,
6177
Steps: []resource.TestStep{
6278
{
63-
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory),
79+
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory),
6480
Check: resource.ComposeTestCheckFunc(
6581
testAccCheckHTTPSourceExists("sumologic_http_source.http", &httpSource),
6682
testAccCheckHTTPSourceValues(&httpSource, sName, sDescription, sCategory),
83+
testAccCheckHTTPSourceExists("sumologic_http_source.traces", &httpTraceSource),
84+
testAccCheckHTTPSourceValues(&httpTraceSource, tName, tDescription, tCategory),
6785
resource.TestCheckResourceAttrSet("sumologic_http_source.http", "id"),
6886
resource.TestCheckResourceAttrSet("sumologic_http_source.http", "url"),
6987
resource.TestCheckResourceAttr("sumologic_http_source.http", "name", sName),
7088
resource.TestCheckResourceAttr("sumologic_http_source.http", "description", sDescription),
7189
resource.TestCheckResourceAttr("sumologic_http_source.http", "message_per_request", "false"),
7290
resource.TestCheckResourceAttr("sumologic_http_source.http", "category", sCategory),
91+
resource.TestCheckResourceAttrSet("sumologic_http_source.traces", "id"),
92+
resource.TestCheckResourceAttrSet("sumologic_http_source.traces", "url"),
93+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "name", tName),
94+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "description", tDescription),
95+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "category", tCategory),
96+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "content_type", "Zipkin"),
7397
),
7498
},
7599
{
76-
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sNameUpdated, sDescriptionUpdated, sCategoryUpdated),
100+
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sNameUpdated, sDescriptionUpdated, sCategoryUpdated, tName, tDescription, tCategory),
77101
Check: resource.ComposeTestCheckFunc(
78102
testAccCheckHTTPSourceExists("sumologic_http_source.http", &httpSource),
79103
testAccCheckHTTPSourceValues(&httpSource, sNameUpdated, sDescriptionUpdated, sCategoryUpdated),
@@ -82,7 +106,7 @@ func TestAccSumologicHTTPSource_update(t *testing.T) {
82106
resource.TestCheckResourceAttr("sumologic_http_source.http", "name", sNameUpdated),
83107
resource.TestCheckResourceAttr("sumologic_http_source.http", "description", sDescriptionUpdated),
84108
resource.TestCheckResourceAttr("sumologic_http_source.http", "category", sCategoryUpdated),
85-
resource.TestCheckResourceAttr("sumologic_http_source.http", "content_type", "Zipkin"),
109+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "content_type", "Zipkin"),
86110
),
87111
},
88112
},
@@ -170,7 +194,7 @@ func testAccCheckHTTPSourceValues(httpSource *HTTPSource, name, description, cat
170194
}
171195
}
172196

173-
func testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory string) string {
197+
func testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory string) string {
174198
return fmt.Sprintf(`
175199
resource "sumologic_collector" "test" {
176200
name = "%s"
@@ -184,7 +208,14 @@ resource "sumologic_http_source" "http" {
184208
message_per_request = false
185209
category = "%s"
186210
collector_id = "${sumologic_collector.test.id}"
211+
}
212+
213+
resource "sumologic_http_source" "traces" {
214+
name = "%s"
215+
description = "%s"
216+
category = "%s"
187217
content_type = "Zipkin"
218+
collector_id = "${sumologic_collector.test.id}"
188219
}
189-
`, cName, cDescription, cCategory, sName, sDescription, sCategory)
220+
`, cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory)
190221
}

0 commit comments

Comments
 (0)