-
Notifications
You must be signed in to change notification settings - Fork 951
Expand file tree
/
Copy pathdata_source_github_team_external_groups_test.go
More file actions
62 lines (54 loc) · 1.66 KB
/
data_source_github_team_external_groups_test.go
File metadata and controls
62 lines (54 loc) · 1.66 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
package github
import (
"fmt"
"regexp"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
"github.com/hashicorp/terraform-plugin-testing/statecheck"
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
)
func TestAccGithubTeamExternalGroupsDataSource(t *testing.T) {
t.Run("errors when querying a non-existing team", func(t *testing.T) {
config := `
data "github_team_external_groups" "test" {
slug = "non-existing-team-slug"
}
`
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessHasOrgs(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: config,
ExpectError: regexp.MustCompile(`Not Found`),
},
},
})
})
t.Run("returns empty list for team without external groups", func(t *testing.T) {
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
teamName := fmt.Sprintf("%steam-%s", testResourcePrefix, randomID)
config := fmt.Sprintf(`
resource "github_team" "test" {
name = "%s"
}
data "github_team_external_groups" "test" {
slug = github_team.test.slug
}
`, teamName)
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessHasOrgs(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: config,
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue("data.github_team_external_groups.test", tfjsonpath.New("external_groups"), knownvalue.ListSizeExact(0)),
},
},
},
})
})
}