@@ -5,8 +5,12 @@ import (
55 "os"
66 "testing"
77
8+ "github.com/hashicorp/terraform-plugin-testing/compare"
89 "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
910 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
11+ "github.com/hashicorp/terraform-plugin-testing/knownvalue"
12+ "github.com/hashicorp/terraform-plugin-testing/statecheck"
13+ "github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
1014)
1115
1216func TestAccGithubEnterpriseTeamDataSource (t * testing.T ) {
@@ -33,12 +37,12 @@ func TestAccGithubEnterpriseTeamDataSource(t *testing.T) {
3337 slug = github_enterprise_team.test.slug
3438 }
3539 ` , testAccConf .enterpriseSlug , testResourcePrefix , randomID ),
36- Check : resource . ComposeAggregateTestCheckFunc (
37- resource . TestCheckResourceAttrSet ("data.github_enterprise_team.by_slug" , "id" ),
38- resource . TestCheckResourceAttrPair ("data.github_enterprise_team.by_slug" , "team_id" , "github_enterprise_team.test" , "team_id" ),
39- resource . TestCheckResourceAttrPair ("data.github_enterprise_team.by_slug" , "slug" , "github_enterprise_team.test" , "slug" ),
40- resource . TestCheckResourceAttrPair ("data.github_enterprise_team.by_slug" , "name" , "github_enterprise_team.test" , "name" ),
41- ) ,
40+ ConfigStateChecks : []statecheck. StateCheck {
41+ statecheck . ExpectKnownValue ("data.github_enterprise_team.by_slug" , tfjsonpath . New ( "id" ), knownvalue . NotNull () ),
42+ statecheck . CompareValuePairs ("data.github_enterprise_team.by_slug" , tfjsonpath . New ( "team_id" ) , "github_enterprise_team.test" , tfjsonpath . New ( "team_id" ), compare . ValuesSame () ),
43+ statecheck . CompareValuePairs ("data.github_enterprise_team.by_slug" , tfjsonpath . New ( "slug" ) , "github_enterprise_team.test" , tfjsonpath . New ( "slug" ), compare . ValuesSame () ),
44+ statecheck . CompareValuePairs ("data.github_enterprise_team.by_slug" , tfjsonpath . New ( "name" ) , "github_enterprise_team.test" , tfjsonpath . New ( "name" ), compare . ValuesSame () ),
45+ } ,
4246 },
4347 },
4448 })
@@ -67,11 +71,11 @@ func TestAccGithubEnterpriseTeamDataSource(t *testing.T) {
6771 team_id = github_enterprise_team.test.team_id
6872 }
6973 ` , testAccConf .enterpriseSlug , testResourcePrefix , randomID ),
70- Check : resource . ComposeAggregateTestCheckFunc (
71- resource . TestCheckResourceAttrSet ("data.github_enterprise_team.by_id" , "id" ),
72- resource . TestCheckResourceAttrPair ("data.github_enterprise_team.by_id" , "team_id" , "github_enterprise_team.test" , "team_id" ),
73- resource . TestCheckResourceAttrPair ("data.github_enterprise_team.by_id" , "slug" , "github_enterprise_team.test" , "slug" ),
74- ) ,
74+ ConfigStateChecks : []statecheck. StateCheck {
75+ statecheck . ExpectKnownValue ("data.github_enterprise_team.by_id" , tfjsonpath . New ( "id" ), knownvalue . NotNull () ),
76+ statecheck . CompareValuePairs ("data.github_enterprise_team.by_id" , tfjsonpath . New ( "team_id" ) , "github_enterprise_team.test" , tfjsonpath . New ( "team_id" ), compare . ValuesSame () ),
77+ statecheck . CompareValuePairs ("data.github_enterprise_team.by_id" , tfjsonpath . New ( "slug" ) , "github_enterprise_team.test" , tfjsonpath . New ( "slug" ), compare . ValuesSame () ),
78+ } ,
7579 },
7680 },
7781 })
@@ -115,11 +119,11 @@ func TestAccGithubEnterpriseTeamOrganizationsDataSource(t *testing.T) {
115119 depends_on = [github_enterprise_team_organizations.assign]
116120 }
117121 ` , testAccConf .enterpriseSlug , testResourcePrefix , randomID , orgSlug ),
118- Check : resource . ComposeAggregateTestCheckFunc (
119- resource . TestCheckResourceAttrSet ("data.github_enterprise_team_organizations.test" , "id" ),
120- resource . TestCheckResourceAttr ("data.github_enterprise_team_organizations.test" , "organization_slugs.#" , "1" ),
121- resource . TestCheckTypeSetElemAttr ("data.github_enterprise_team_organizations.test" , "organization_slugs.*" , orgSlug ),
122- ) ,
122+ ConfigStateChecks : []statecheck. StateCheck {
123+ statecheck . ExpectKnownValue ("data.github_enterprise_team_organizations.test" , tfjsonpath . New ( "id" ), knownvalue . NotNull () ),
124+ statecheck . ExpectKnownValue ("data.github_enterprise_team_organizations.test" , tfjsonpath . New ( "organization_slugs" ), knownvalue . SetSizeExact ( 1 ) ),
125+ statecheck . ExpectKnownValue ("data.github_enterprise_team_organizations.test" , tfjsonpath . New ( "organization_slugs" ), knownvalue . SetPartial ([]knownvalue. Check { knownvalue . StringExact ( orgSlug )}) ),
126+ } ,
123127 },
124128 },
125129 })
@@ -163,10 +167,10 @@ func TestAccGithubEnterpriseTeamMembershipDataSource(t *testing.T) {
163167 depends_on = [github_enterprise_team_membership.test]
164168 }
165169 ` , testAccConf .enterpriseSlug , testResourcePrefix , randomID , username , username ),
166- Check : resource . ComposeAggregateTestCheckFunc (
167- resource . TestCheckResourceAttrSet ("data.github_enterprise_team_membership.test" , "id" ),
168- resource . TestCheckResourceAttr ("data.github_enterprise_team_membership.test" , "username" , username ),
169- ) ,
170+ ConfigStateChecks : []statecheck. StateCheck {
171+ statecheck . ExpectKnownValue ("data.github_enterprise_team_membership.test" , tfjsonpath . New ( "id" ), knownvalue . NotNull () ),
172+ statecheck . ExpectKnownValue ("data.github_enterprise_team_membership.test" , tfjsonpath . New ( "username" ), knownvalue . StringExact ( username ) ),
173+ } ,
170174 },
171175 },
172176 })
0 commit comments