-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding resource github_organization_settings to provider closes#1125 (#…
…1298) * adding resouce github_settings to provider * Spacing and comment changes Co-authored-by: Keegan Campbell <me@kfcampbell.com>
- Loading branch information
1 parent
aaf1a88
commit 759426b
Showing
30 changed files
with
894 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
package github | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccGithubOrganizationSettings(t *testing.T) { | ||
t.Run("creates organization settings without error", func(t *testing.T) { | ||
|
||
config := ` | ||
resource "github_organization_settings" "test" { | ||
billing_email = "test@example.com" | ||
company = "Test Company" | ||
blog = "https://example.com" | ||
email = "test@example.com" | ||
twitter_username = "Test" | ||
location = "Test Location" | ||
name = "Test Name" | ||
description = "Test Description" | ||
has_organization_projects = true | ||
has_repository_projects = true | ||
default_repository_permission = "read" | ||
members_can_create_repositories = true | ||
members_can_create_public_repositories = true | ||
members_can_create_private_repositories = true | ||
members_can_create_internal_repositories = false | ||
members_can_create_pages = true | ||
members_can_create_public_pages = true | ||
members_can_create_private_pages = true | ||
members_can_fork_private_repositories = true | ||
web_commit_signoff_required = true | ||
advanced_security_enabled_for_new_repositories = false | ||
dependabot_alerts_enabled_for_new_repositories= false | ||
dependabot_security_updates_enabled_for_new_repositories = false | ||
dependency_graph_enabled_for_new_repositories = false | ||
secret_scanning_enabled_for_new_repositories = false | ||
secret_scanning_push_protection_enabled_for_new_repositories = false | ||
}` | ||
|
||
check := resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr( | ||
"github_organization_settings.test", | ||
"billing_email", "test@example.com", | ||
), | ||
) | ||
testCase := func(t *testing.T, mode string) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { skipUnlessMode(t, mode) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
Check: check, | ||
}, | ||
}, | ||
}) | ||
} | ||
t.Run("run with an anonymous account", func(t *testing.T) { | ||
t.Skip("anonymous account not supported for this operation") | ||
}) | ||
t.Run("run with an individual account", func(t *testing.T) { | ||
t.Skip("individual account not supported for this operation") | ||
}) | ||
t.Run("run with an organization account", func(t *testing.T) { | ||
testCase(t, organization) | ||
}) | ||
|
||
}) | ||
t.Run("updates organization settings without error", func(t *testing.T) { | ||
billingEmail := "test1@example.com" | ||
company := "Test Company" | ||
blog := "https://test.com" | ||
updatedBillingEmail := "test2@example.com" | ||
updatedCompany := "Test Company 2" | ||
updatedBlog := "https://test2.com" | ||
|
||
configs := map[string]string{ | ||
"before": fmt.Sprintf(` | ||
resource "github_organization_settings" "test" { | ||
billing_email = "%s" | ||
company = "%s" | ||
blog = "%s" | ||
}`, billingEmail, company, blog), | ||
|
||
"after": fmt.Sprintf(` | ||
resource "github_organization_settings" "test" { | ||
billing_email = "%s" | ||
company = "%s" | ||
blog = "%s" | ||
}`, updatedBillingEmail, updatedCompany, updatedBlog), | ||
} | ||
checks := map[string]resource.TestCheckFunc{ | ||
"before": resource.TestCheckResourceAttr( | ||
"github_organization_settings.test", | ||
"billing_email", billingEmail, | ||
), | ||
"after": resource.TestCheckResourceAttr( | ||
"github_organization_settings.test", | ||
"billing_email", updatedBillingEmail, | ||
), | ||
} | ||
testCase := func(t *testing.T, mode string) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { skipUnlessMode(t, mode) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: configs["before"], | ||
Check: checks["before"], | ||
}, | ||
{ | ||
Config: configs["after"], | ||
Check: checks["after"], | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
t.Run("with an anonymous account", func(t *testing.T) { | ||
t.Skip("anonymous account not supported for this operation") | ||
}) | ||
|
||
t.Run("with an individual account", func(t *testing.T) { | ||
t.Skip("individual account not supported for this operation") | ||
}) | ||
|
||
t.Run("with an organization account", func(t *testing.T) { | ||
testCase(t, organization) | ||
}) | ||
}) | ||
|
||
t.Run("imports organization settings without error", func(t *testing.T) { | ||
billingEmail := "test@example.com" | ||
company := "Test Company" | ||
blog := "https://example.com" | ||
|
||
config := fmt.Sprintf(` | ||
resource "github_organization_settings" "test" { | ||
billing_email = "%s" | ||
company = "%s" | ||
blog = "%s" | ||
}`, billingEmail, company, blog) | ||
|
||
check := resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr( | ||
"github_organization_settings.test", | ||
"billing_email", billingEmail, | ||
), | ||
) | ||
|
||
testCase := func(t *testing.T, mode string) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { skipUnlessMode(t, mode) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
Check: check, | ||
}, | ||
{ | ||
ResourceName: "github_organization_settings.test", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
t.Run("with an anonymous account", func(t *testing.T) { | ||
t.Skip("anonymous account not supported for this operation") | ||
}) | ||
|
||
t.Run("with an individual account", func(t *testing.T) { | ||
t.Skip("individual account not supported for this operation") | ||
}) | ||
|
||
t.Run("with an organization account", func(t *testing.T) { | ||
testCase(t, organization) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
44 changes: 24 additions & 20 deletions
44
vendor/github.com/google/go-cmp/cmp/internal/diff/diff.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.