-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_source_openstack_identity_group_v3_test.go
More file actions
50 lines (43 loc) · 1.19 KB
/
Copy pathdata_source_openstack_identity_group_v3_test.go
File metadata and controls
50 lines (43 loc) · 1.19 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package openstack
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
func TestAccOpenStackIdentityV3GroupDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
testAccPreCheckAdminOnly(t)
},
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOpenStackIdentityV3GroupDataSourceBasic,
Check: resource.ComposeTestCheckFunc(
testAccCheckIdentityV3GroupDataSourceID("data.openstack_identity_group_v3.group_1"),
resource.TestCheckResourceAttr(
"data.openstack_identity_group_v3.group_1", "name", "admins"),
),
},
},
})
}
func testAccCheckIdentityV3GroupDataSourceID(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Can't find group data source: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("Group data source ID not set")
}
return nil
}
}
const testAccOpenStackIdentityV3GroupDataSourceBasic = `
data "openstack_identity_group_v3" "group_1" {
name = "admins"
}
`