/
list_acctest.go
34 lines (28 loc) · 982 Bytes
/
list_acctest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package serverRole
import (
"github.com/PGSSoft/terraform-provider-mssql/internal/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func testListDataSource(testCtx *acctest.TestContext) {
if testCtx.IsAzureTest {
return
}
testCtx.ExecMasterDB("CREATE SERVER ROLE [test_owner]")
defer testCtx.ExecMasterDB("DROP SERVER ROLE [test_owner]")
testCtx.ExecMasterDB("CREATE SERVER ROLE [test_list_role] AUTHORIZATION [test_owner]")
defer testCtx.ExecMasterDB("DROP SERVER ROLE [test_list_role]")
ownerId := fetchPrincipalId(testCtx, "'test_owner'")
roleId := fetchPrincipalId(testCtx, "'test_list_role'")
testCtx.Test(resource.TestCase{
Steps: []resource.TestStep{
{
Config: `data "mssql_server_roles" "all" {}`,
Check: resource.TestCheckTypeSetElemNestedAttrs("data.mssql_server_roles.all", "roles.*", map[string]string{
"id": roleId,
"name": "test_list_role",
"owner_id": ownerId,
}),
},
},
})
}