|
7 | 7 |
|
8 | 8 | "github.com/hashicorp/terraform-plugin-testing/helper/resource"
|
9 | 9 | "github.com/hashicorp/terraform-plugin-testing/terraform"
|
| 10 | + |
10 | 11 | "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
|
11 | 12 | )
|
12 | 13 |
|
@@ -178,23 +179,57 @@ func datadogTest(tb testing.TB) *resource.TestCase {
|
178 | 179 | CheckDestroy: checkDestroy,
|
179 | 180 | Steps: []resource.TestStep{
|
180 | 181 | {
|
181 |
| - Config: configDatadog(projectID, apiKey, "US"), |
| 182 | + Config: configDatadog(projectID, apiKey, "US", false, false, false), |
| 183 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 184 | + checkExists(resourceName), |
| 185 | + resource.TestCheckResourceAttr(resourceName, "type", intType), |
| 186 | + resource.TestCheckResourceAttr(resourceName, "api_key", apiKey), |
| 187 | + resource.TestCheckResourceAttr(resourceName, "region", region), |
| 188 | + resource.TestCheckResourceAttr(resourceName, "send_collection_latency_metrics", "false"), |
| 189 | + resource.TestCheckResourceAttr(resourceName, "send_database_metrics", "false"), |
| 190 | + resource.TestCheckResourceAttr(dataSourceName, "type", intType), |
| 191 | + resource.TestCheckResourceAttr(dataSourceName, "region", region), |
| 192 | + resource.TestCheckResourceAttr(dataSourceName, "send_collection_latency_metrics", "false"), |
| 193 | + resource.TestCheckResourceAttr(dataSourceName, "send_database_metrics", "false"), |
| 194 | + ), |
| 195 | + }, |
| 196 | + { |
| 197 | + Config: configDatadog(projectID, apiKey, "US", true, true, false), |
182 | 198 | Check: resource.ComposeAggregateTestCheckFunc(
|
183 | 199 | checkExists(resourceName),
|
184 | 200 | resource.TestCheckResourceAttr(resourceName, "type", intType),
|
185 | 201 | resource.TestCheckResourceAttr(resourceName, "api_key", apiKey),
|
186 | 202 | resource.TestCheckResourceAttr(resourceName, "region", region),
|
| 203 | + resource.TestCheckResourceAttr(resourceName, "send_collection_latency_metrics", "true"), |
| 204 | + resource.TestCheckResourceAttr(resourceName, "send_database_metrics", "false"), |
187 | 205 | resource.TestCheckResourceAttr(dataSourceName, "type", intType),
|
188 | 206 | resource.TestCheckResourceAttr(dataSourceName, "region", region),
|
| 207 | + resource.TestCheckResourceAttr(dataSourceName, "send_collection_latency_metrics", "true"), |
| 208 | + resource.TestCheckResourceAttr(dataSourceName, "send_database_metrics", "false"), |
| 209 | + ), |
| 210 | + }, |
| 211 | + { |
| 212 | + Config: configDatadog(projectID, updatedAPIKey, "US", true, false, true), |
| 213 | + Check: resource.ComposeAggregateTestCheckFunc( |
| 214 | + checkExists(resourceName), |
| 215 | + resource.TestCheckResourceAttr(resourceName, "type", intType), |
| 216 | + resource.TestCheckResourceAttr(resourceName, "api_key", updatedAPIKey), |
| 217 | + resource.TestCheckResourceAttr(resourceName, "region", region), |
| 218 | + resource.TestCheckResourceAttr(resourceName, "send_collection_latency_metrics", "false"), |
| 219 | + resource.TestCheckResourceAttr(resourceName, "send_database_metrics", "true"), |
189 | 220 | ),
|
190 | 221 | },
|
191 | 222 | {
|
192 |
| - Config: configDatadog(projectID, updatedAPIKey, "US"), |
| 223 | + Config: configDatadog(projectID, updatedAPIKey, "US", true, true, true), |
193 | 224 | Check: resource.ComposeAggregateTestCheckFunc(
|
194 | 225 | checkExists(resourceName),
|
195 | 226 | resource.TestCheckResourceAttr(resourceName, "type", intType),
|
196 | 227 | resource.TestCheckResourceAttr(resourceName, "api_key", updatedAPIKey),
|
197 | 228 | resource.TestCheckResourceAttr(resourceName, "region", region),
|
| 229 | + resource.TestCheckResourceAttr(resourceName, "send_collection_latency_metrics", "true"), |
| 230 | + resource.TestCheckResourceAttr(resourceName, "send_database_metrics", "true"), |
| 231 | + resource.TestCheckResourceAttr(dataSourceName, "send_collection_latency_metrics", "true"), |
| 232 | + resource.TestCheckResourceAttr(dataSourceName, "send_database_metrics", "true"), |
198 | 233 | ),
|
199 | 234 | },
|
200 | 235 | importStep(resourceName),
|
@@ -424,19 +459,28 @@ func configVictorOps(projectID, apiKey string) string {
|
424 | 459 | ) + singularDataStr
|
425 | 460 | }
|
426 | 461 |
|
427 |
| -func configDatadog(projectID, apiKey, region string) string { |
| 462 | +func configDatadog(projectID, apiKey, region string, useOptionalAttr, sendCollectionLatencyMetrics, sendDatabaseMetrics bool) string { |
| 463 | + optionalConfigAttrs := "" |
| 464 | + if useOptionalAttr { |
| 465 | + optionalConfigAttrs = fmt.Sprintf( |
| 466 | + `send_collection_latency_metrics = %[1]t |
| 467 | + send_database_metrics = %[2]t`, sendCollectionLatencyMetrics, sendDatabaseMetrics) |
| 468 | + } |
428 | 469 | return fmt.Sprintf(`
|
429 | 470 | resource "mongodbatlas_third_party_integration" "test" {
|
430 | 471 | project_id = "%[1]s"
|
431 | 472 | type = "%[2]s"
|
432 | 473 | api_key = "%[3]s"
|
433 | 474 | region ="%[4]s"
|
| 475 | + |
| 476 | + %[5]s |
434 | 477 | }
|
435 | 478 | `,
|
436 | 479 | projectID,
|
437 | 480 | "DATADOG",
|
438 | 481 | apiKey,
|
439 | 482 | region,
|
| 483 | + optionalConfigAttrs, |
440 | 484 | ) + singularDataStr
|
441 | 485 | }
|
442 | 486 |
|
|
0 commit comments