Skip to content

Commit 7f9672c

Browse files
committed
Use ConfigStateChecks in DS tests
Signed-off-by: Timo Sand <[email protected]>
1 parent 4740338 commit 7f9672c

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

github/data_source_github_repository_pages.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func dataSourceGithubRepositoryPages() *schema.Resource {
6969
Computed: true,
7070
Description: "The GitHub Pages site's build status e.g. 'building' or 'built'.",
7171
},
72-
"url": {
72+
"api_url": {
7373
Type: schema.TypeString,
7474
Computed: true,
7575
Description: "The API URL of the GitHub Pages resource.",
@@ -115,7 +115,7 @@ func dataSourceGithubRepositoryPagesRead(ctx context.Context, d *schema.Resource
115115
if err := d.Set("status", pages.GetStatus()); err != nil {
116116
return diag.FromErr(err)
117117
}
118-
if err := d.Set("url", pages.GetURL()); err != nil {
118+
if err := d.Set("api_url", pages.GetURL()); err != nil {
119119
return diag.FromErr(err)
120120
}
121121

github/data_source_github_repository_pages_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import (
44
"fmt"
55
"testing"
66

7+
"github.com/hashicorp/terraform-plugin-testing/compare"
78
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
89
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
10+
"github.com/hashicorp/terraform-plugin-testing/statecheck"
11+
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
912
)
1013

1114
func TestAccGithubRepositoryPagesDataSource(t *testing.T) {
@@ -49,12 +52,12 @@ func TestAccGithubRepositoryPagesDataSource(t *testing.T) {
4952
Steps: []resource.TestStep{
5053
{
5154
Config: config,
52-
Check: resource.ComposeTestCheckFunc(
53-
resource.TestCheckResourceAttr("data.github_repository_pages.test", "build_type", "legacy"),
54-
resource.TestCheckResourceAttr("data.github_repository_pages.test", "source.0.branch", "main"),
55-
resource.TestCheckResourceAttr("data.github_repository_pages.test", "source.0.path", "/"),
56-
resource.TestCheckResourceAttrSet("data.github_repository_pages.test", "url"),
57-
),
55+
ConfigStateChecks: []statecheck.StateCheck{
56+
statecheck.CompareValuePairs("data.github_repository_pages.test", tfjsonpath.New("build_type"), "github_repository_pages.test", tfjsonpath.New("build_type"), compare.ValuesSame()),
57+
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()),
58+
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()),
59+
statecheck.CompareValuePairs("data.github_repository_pages.test", tfjsonpath.New("api_url"), "github_repository_pages.test", tfjsonpath.New("api_url"), compare.ValuesSame()),
60+
},
5861
},
5962
},
6063
})

0 commit comments

Comments
 (0)