Skip to content

Commit e556c1b

Browse files
author
Abhishek Singh
committed
SUMO-266317: Adding Test case as per recommnendation
1 parent d89463f commit e556c1b

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

sumologic/resource_sumologic_role_v2_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,59 @@ resource "sumologic_role_v2" "test" {
218218
`, name, auditDataFilter, selectionType, capabilities, description, securityDataFilter, logAnalyticsFilter)
219219
}
220220

221+
func TestAccSumologicRoleV2_selectionTypeOptional(t *testing.T) {
222+
var roleV2 RoleV2
223+
testName := acctest.RandomWithPrefix("tf-acc-test")
224+
testCapabilities := []string{"\"manageContent\""}
225+
testDescription := "Role with optional selection_type"
226+
testAuditDataFilter := "info"
227+
testSecurityDataFilter := "error"
228+
testLogAnalyticsFilter := "!_sourceCategory=collector"
229+
230+
resource.Test(t, resource.TestCase{
231+
PreCheck: func() { testAccPreCheck(t) },
232+
Providers: testAccProviders,
233+
CheckDestroy: testAccCheckRoleV2Destroy(roleV2),
234+
Steps: []resource.TestStep{
235+
// Step 1: selection_type is not set at all
236+
{
237+
Config: fmt.Sprintf(`
238+
resource "sumologic_role_v2" "test" {
239+
name = "%s"
240+
audit_data_filter = "%s"
241+
capabilities = %v
242+
description = "%s"
243+
security_data_filter = "%s"
244+
log_analytics_filter = "%s"
245+
}
246+
`, testName, testAuditDataFilter, testCapabilities, testDescription, testSecurityDataFilter, testLogAnalyticsFilter),
247+
Check: resource.ComposeTestCheckFunc(
248+
testAccCheckRoleV2Exists("sumologic_role_v2.test", &roleV2, t),
249+
resource.TestCheckResourceAttr("sumologic_role_v2.test", "selection_type", ""),
250+
),
251+
},
252+
// Step 2: Explicitly set selection_type = ""
253+
{
254+
Config: fmt.Sprintf(`
255+
resource "sumologic_role_v2" "test" {
256+
name = "%s"
257+
audit_data_filter = "%s"
258+
selection_type = ""
259+
capabilities = %v
260+
description = "%s"
261+
security_data_filter = "%s"
262+
log_analytics_filter = "%s"
263+
}
264+
`, testName, testAuditDataFilter, testCapabilities, testDescription, testSecurityDataFilter, testLogAnalyticsFilter),
265+
Check: resource.ComposeTestCheckFunc(
266+
testAccCheckRoleV2Exists("sumologic_role_v2.test", &roleV2, t),
267+
resource.TestCheckResourceAttr("sumologic_role_v2.test", "selection_type", ""),
268+
),
269+
},
270+
},
271+
})
272+
}
273+
221274
func testAccCheckRoleV2Attributes(name string) resource.TestCheckFunc {
222275
return func(s *terraform.State) error {
223276
f := resource.ComposeTestCheckFunc(

0 commit comments

Comments
 (0)