-
Notifications
You must be signed in to change notification settings - Fork 966
Expand file tree
/
Copy pathdata_source_github_organization_repositories_test.go
More file actions
73 lines (63 loc) · 2.19 KB
/
data_source_github_organization_repositories_test.go
File metadata and controls
73 lines (63 loc) · 2.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package github
import (
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccGithubOrganizationRepositoriesDataSource(t *testing.T) {
t.Run("manages repositories", func(t *testing.T) {
config := `
resource "github_repository" "test1" {
name = "test1"
visibility = "private"
}
resource "github_repository" "test2" {
name = "test2"
archived = true
visibility = "public"
depends_on = [github_repository.test1]
}
`
config2 := config + `
data "github_organization_repositories" "all" {}
`
const resourceName = "data.github_organization_repositories.all"
check := resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "webhooks.#", "2"),
resource.TestCheckResourceAttr(resourceName, "webhooks.0.name", "test1"),
resource.TestCheckResourceAttr(resourceName, "webhooks.0.archived", "false"),
resource.TestCheckResourceAttr(resourceName, "webhooks.0.visibility", "private"),
resource.TestCheckResourceAttrSet(resourceName, "webhooks.0.repo_id"),
resource.TestCheckResourceAttrSet(resourceName, "webhooks.0.node_id"),
resource.TestCheckResourceAttr(resourceName, "webhooks.1.name", "test2"),
resource.TestCheckResourceAttr(resourceName, "webhooks.1.archived", "true"),
resource.TestCheckResourceAttr(resourceName, "webhooks.1.visibility", "public"),
resource.TestCheckResourceAttrSet(resourceName, "webhooks.1.repo_id"),
resource.TestCheckResourceAttrSet(resourceName, "webhooks.1.node_id"),
)
testCase := func(t *testing.T, mode string) {
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessMode(t, mode) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(),
},
{
Config: config2,
Check: check,
},
},
})
}
t.Run("with an anonymous account", func(t *testing.T) {
t.Skip("anonymous account not supported for this operation")
})
t.Run("with an individual account", func(t *testing.T) {
testCase(t, individual)
})
t.Run("with an organization account", func(t *testing.T) {
testCase(t, organization)
})
})
}