@@ -2,12 +2,13 @@ package sumologic
22
33import (
44 "fmt"
5+ "regexp"
56 "testing"
67
78 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
89)
910
10- func TestAccDataSourcSumologicUser_basic (t * testing.T ) {
11+ func TestAccDataSourceSumologicUser_basic (t * testing.T ) {
1112 resource .Test (t , resource.TestCase {
1213 PreCheck : func () { testAccPreCheck (t ) },
1314 Providers : testAccProviders ,
@@ -34,6 +35,40 @@ func testAccDataSourceUserCheck(email, reference string) resource.TestCheckFunc
3435 )
3536}
3637
38+ func TestAccDataSourceSumologicUser_user_email_doesnt_exist (t * testing.T ) {
39+ userDoestExistConfig := `
40+ data "sumologic_user" "user_email_doesnt_exist" {
41+ 42+ }`
43+ resource .Test (t , resource.TestCase {
44+ PreCheck : func () { testAccPreCheck (t ) },
45+ Providers : testAccProviders ,
46+ Steps : []resource.TestStep {
47+ {
48+ Config : userDoestExistConfig ,
49+ ExpectError :
regexp .
MustCompile (
"user with email address '[email protected] ' does not exist" ),
50+ },
51+ },
52+ })
53+ }
54+
55+ func TestAccDataSourceSumologicUser_user_id_doesnt_exist (t * testing.T ) {
56+ userDoestExistConfig := `
57+ data "sumologic_user" "user_id_doesnt_exist" {
58+ id = 99999999999999
59+ }`
60+ resource .Test (t , resource.TestCase {
61+ PreCheck : func () { testAccPreCheck (t ) },
62+ Providers : testAccProviders ,
63+ Steps : []resource.TestStep {
64+ {
65+ Config : userDoestExistConfig ,
66+ ExpectError : regexp .MustCompile ("user with id 99999999999999 not found" ),
67+ },
68+ },
69+ })
70+ }
71+
3772var testDataSourceAccSumologicUserConfig = fmt .Sprintf (`
3873resource "sumologic_user" "test_user" {
3974 first_name = "Test"
0 commit comments