Skip to content

Commit 09ec3a0

Browse files
test: add test for github_organization owner fallback
Verify that omitting 'name' from the data source falls back to the provider's configured owner. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f83cc47 commit 09ec3a0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

github/data_source_github_organization_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,32 @@ import (
66

77
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
88
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
10+
"github.com/hashicorp/terraform-plugin-testing/statecheck"
11+
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
912
)
1013

1114
func TestAccGithubOrganizationDataSource(t *testing.T) {
15+
t.Run("uses provider owner when name is not set", func(t *testing.T) {
16+
config := `data "github_organization" "test" {}`
17+
18+
resource.Test(t, resource.TestCase{
19+
PreCheck: func() { skipUnlessHasOrgs(t) },
20+
ProviderFactories: providerFactories,
21+
Steps: []resource.TestStep{
22+
{
23+
Config: config,
24+
ConfigStateChecks: []statecheck.StateCheck{
25+
statecheck.ExpectKnownValue("data.github_organization.test", tfjsonpath.New("login"), knownvalue.StringExact(testAccConf.owner)),
26+
statecheck.ExpectKnownValue("data.github_organization.test", tfjsonpath.New("orgname"), knownvalue.StringExact(testAccConf.owner)),
27+
statecheck.ExpectKnownValue("data.github_organization.test", tfjsonpath.New("node_id"), knownvalue.NotNull()),
28+
statecheck.ExpectKnownValue("data.github_organization.test", tfjsonpath.New("plan"), knownvalue.NotNull()),
29+
},
30+
},
31+
},
32+
})
33+
})
34+
1235
t.Run("queries for an organization without error", func(t *testing.T) {
1336
config := fmt.Sprintf(`
1437
data "github_organization" "test" {

0 commit comments

Comments
 (0)