New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding resource github_organization_settings to provider closes#1125 #1298
Merged
kfcampbell
merged 2 commits into
integrations:main
from
kuhlman-labs:feature/github_organization_settings
Sep 21, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are passing for me locally!