77 "github.com/hashicorp/terraform-plugin-testing/compare"
88 "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
99 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
10+ "github.com/hashicorp/terraform-plugin-testing/knownvalue"
1011 "github.com/hashicorp/terraform-plugin-testing/statecheck"
1112 "github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
1213)
@@ -45,7 +46,58 @@ func TestAccGithubRepositoryPagesDataSource(t *testing.T) {
4546 ` , repoName , baseRepoVisibility )
4647
4748 resource .Test (t , resource.TestCase {
48- PreCheck : func () { skipUnauthenticated (t ) },
49+ PreCheck : func () {
50+ skipUnauthenticated (t )
51+ },
52+ ProviderFactories : providerFactories ,
53+ Steps : []resource.TestStep {
54+ {
55+ Config : config ,
56+ ConfigStateChecks : []statecheck.StateCheck {
57+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("build_type" ), "github_repository_pages.test" , tfjsonpath .New ("build_type" ), compare .ValuesSame ()),
58+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("source" ).AtSliceIndex (0 ).AtMapKey ("branch" ), "github_repository_pages.test" , tfjsonpath .New ("source" ).AtSliceIndex (0 ).AtMapKey ("branch" ), compare .ValuesSame ()),
59+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("source" ).AtSliceIndex (0 ).AtMapKey ("path" ), "github_repository_pages.test" , tfjsonpath .New ("source" ).AtSliceIndex (0 ).AtMapKey ("path" ), compare .ValuesSame ()),
60+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("cname" ), "github_repository_pages.test" , tfjsonpath .New ("cname" ), compare .ValuesSame ()),
61+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("custom_404" ), "github_repository_pages.test" , tfjsonpath .New ("custom_404" ), compare .ValuesSame ()),
62+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("html_url" ), "github_repository_pages.test" , tfjsonpath .New ("html_url" ), compare .ValuesSame ()),
63+ statecheck .ExpectKnownValue ("data.github_repository_pages.test" , tfjsonpath .New ("build_status" ), knownvalue .NotNull ()),
64+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("api_url" ), "github_repository_pages.test" , tfjsonpath .New ("api_url" ), compare .ValuesSame ()),
65+ statecheck .ExpectKnownValue ("data.github_repository_pages.test" , tfjsonpath .New ("public" ), knownvalue .Bool (testAccConf .authMode != enterprise )),
66+ },
67+ },
68+ },
69+ })
70+ })
71+ t .Run ("reads_pages_enterprise_configuration" , func (t * testing.T ) {
72+ randomID := acctest .RandString (5 )
73+ repoName := fmt .Sprintf ("%spages-ds-%s" , testResourcePrefix , randomID )
74+
75+ config := fmt .Sprintf (`
76+ resource "github_repository" "test" {
77+ name = "%s"
78+ visibility = "%s"
79+ auto_init = true
80+ }
81+
82+ resource "github_repository_pages" "test" {
83+ repository = github_repository.test.name
84+ build_type = "legacy"
85+ source {
86+ branch = "main"
87+ path = "/"
88+ }
89+ public = false
90+ }
91+
92+ data "github_repository_pages" "test" {
93+ repository = github_repository.test.name
94+
95+ depends_on = [github_repository_pages.test]
96+ }
97+ ` , repoName , baseRepoVisibility )
98+
99+ resource .Test (t , resource.TestCase {
100+ PreCheck : func () { skipUnlessEnterprise (t ) },
49101 ProviderFactories : providerFactories ,
50102 Steps : []resource.TestStep {
51103 {
@@ -54,7 +106,12 @@ func TestAccGithubRepositoryPagesDataSource(t *testing.T) {
54106 statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("build_type" ), "github_repository_pages.test" , tfjsonpath .New ("build_type" ), compare .ValuesSame ()),
55107 statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("source" ).AtSliceIndex (0 ).AtMapKey ("branch" ), "github_repository_pages.test" , tfjsonpath .New ("source" ).AtSliceIndex (0 ).AtMapKey ("branch" ), compare .ValuesSame ()),
56108 statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("source" ).AtSliceIndex (0 ).AtMapKey ("path" ), "github_repository_pages.test" , tfjsonpath .New ("source" ).AtSliceIndex (0 ).AtMapKey ("path" ), compare .ValuesSame ()),
109+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("cname" ), "github_repository_pages.test" , tfjsonpath .New ("cname" ), compare .ValuesSame ()),
110+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("custom_404" ), "github_repository_pages.test" , tfjsonpath .New ("custom_404" ), compare .ValuesSame ()),
111+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("html_url" ), "github_repository_pages.test" , tfjsonpath .New ("html_url" ), compare .ValuesSame ()),
112+ statecheck .ExpectKnownValue ("data.github_repository_pages.test" , tfjsonpath .New ("build_status" ), knownvalue .NotNull ()),
57113 statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("api_url" ), "github_repository_pages.test" , tfjsonpath .New ("api_url" ), compare .ValuesSame ()),
114+ statecheck .CompareValuePairs ("data.github_repository_pages.test" , tfjsonpath .New ("public" ), "github_repository_pages.test" , tfjsonpath .New ("public" ), compare .ValuesSame ()),
58115 },
59116 },
60117 },
0 commit comments