forked from integrations/terraform-provider-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_source_github_organization_custom_role_test.go
More file actions
71 lines (64 loc) · 1.79 KB
/
data_source_github_organization_custom_role_test.go
File metadata and controls
71 lines (64 loc) · 1.79 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package github
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccGithubOrganizationCustomRoleDataSource(t *testing.T) {
t.Run("queries a custom repo role", func(t *testing.T) {
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
testResourceName := fmt.Sprintf("%sorg-custom-role-%s", testResourcePrefix, randomID)
config := fmt.Sprintf(`
resource "github_organization_custom_role" "test" {
name = "%s"
description = "Test role description"
base_role = "read"
permissions = [
"reopen_issue",
"reopen_pull_request",
]
}
`, testResourceName)
config2 := config + `
data "github_organization_custom_role" "test" {
name = github_organization_custom_role.test.name
}
`
check := resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(
"data.github_organization_custom_role.test", "name",
),
resource.TestCheckResourceAttr(
"data.github_organization_custom_role.test", "name",
testResourceName,
),
resource.TestCheckResourceAttr(
"data.github_organization_custom_role.test", "description",
"Test role description",
),
resource.TestCheckResourceAttr(
"data.github_organization_custom_role.test", "base_role",
"read",
),
resource.TestCheckResourceAttr(
"data.github_organization_custom_role.test", "permissions.#",
"2",
),
)
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessHasPaidOrgs(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(),
},
{
Config: config2,
Check: check,
},
},
})
})
}