Skip to content

Commit 92130b5

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 92130b5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

github/data_source_github_organization_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ import (
99
)
1010

1111
func TestAccGithubOrganizationDataSource(t *testing.T) {
12+
t.Run("uses provider owner when name is not set", func(t *testing.T) {
13+
config := `
14+
data "github_organization" "test" {}
15+
`
16+
17+
check := resource.ComposeTestCheckFunc(
18+
resource.TestCheckResourceAttr("data.github_organization.test", "login", testAccConf.owner),
19+
resource.TestCheckResourceAttr("data.github_organization.test", "orgname", testAccConf.owner),
20+
resource.TestCheckResourceAttrSet("data.github_organization.test", "node_id"),
21+
resource.TestCheckResourceAttrSet("data.github_organization.test", "plan"),
22+
)
23+
24+
resource.Test(t, resource.TestCase{
25+
PreCheck: func() { skipUnlessHasOrgs(t) },
26+
ProviderFactories: providerFactories,
27+
Steps: []resource.TestStep{
28+
{
29+
Config: config,
30+
Check: check,
31+
},
32+
},
33+
})
34+
})
35+
1236
t.Run("queries for an organization without error", func(t *testing.T) {
1337
config := fmt.Sprintf(`
1438
data "github_organization" "test" {

0 commit comments

Comments
 (0)