11package sumologic
22
33import (
4+ "regexp"
45 "testing"
56
67 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
78)
89
9- func TestAccDataSourcSumologicRole_basic (t * testing.T ) {
10+ func TestAccDataSourceSumologicRole_basic (t * testing.T ) {
1011 resource .Test (t , resource.TestCase {
1112 PreCheck : func () { testAccPreCheck (t ) },
1213 Providers : testAccProviders ,
@@ -33,6 +34,40 @@ func testAccDataSourceRoleCheck(name, reference string) resource.TestCheckFunc {
3334 )
3435}
3536
37+ func TestAccDataSourceSumologicRole_role_name_doesnt_exist (t * testing.T ) {
38+ roleDoestExistConfig := `
39+ data "sumologic_role" "role_name_doesnt_exist" {
40+ name = "someRoleNameDoesntExist8746"
41+ }`
42+ resource .Test (t , resource.TestCase {
43+ PreCheck : func () { testAccPreCheck (t ) },
44+ Providers : testAccProviders ,
45+ Steps : []resource.TestStep {
46+ {
47+ Config : roleDoestExistConfig ,
48+ ExpectError : regexp .MustCompile ("role with name 'someRoleNameDoesntExist8746' does not exist" ),
49+ },
50+ },
51+ })
52+ }
53+
54+ func TestAccDataSourceSumologicRole_role_id_doesnt_exist (t * testing.T ) {
55+ roleDoestExistConfig := `
56+ data "sumologic_role" "role_id_doesnt_exist" {
57+ id = 99999999999999
58+ }`
59+ resource .Test (t , resource.TestCase {
60+ PreCheck : func () { testAccPreCheck (t ) },
61+ Providers : testAccProviders ,
62+ Steps : []resource.TestStep {
63+ {
64+ Config : roleDoestExistConfig ,
65+ ExpectError : regexp .MustCompile ("role with id 99999999999999 not found" ),
66+ },
67+ },
68+ })
69+ }
70+
3671var testDataSourceAccSumologicRoleConfig = `
3772resource "sumologic_role" "test" {
3873 name = "My_SumoRole"
0 commit comments