Skip to content

Commit

Permalink
site settings test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonsnir committed Sep 2, 2024
1 parent 9074bf9 commit f9fbc16
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ openapi_generate: ## Generate the go code from the OpenAPI spec.
-o /local/internal/netlifyapi ; \
sed -i '' 's/int32/int64/g' internal/netlifyapi/model_*.go ; \
sed -i '' 's/int32/int64/g' internal/netlifyapi/api_*.go ; \
sed -i '' 's/return e.error/return fmt.Sprintf("%s: %q", e.error, e.body)/g' internal/netlifyapi/client.go
sed -i '' 's/return e.error/return fmt.Sprintf("%s: %s", e.error, e.body)/g' internal/netlifyapi/client.go

test: ## Test the go code.
go test -v ./...
Expand Down
3 changes: 2 additions & 1 deletion UPDATING_OPENAPI_JSON.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This project uses a modified `openapi.json`. Please maintain these instructions
1. Remove the `values`, `scopes` and `is_secret` parameters from the `updateEnvVar` operation.
1. Add a request body schema to the `updateEnvVar` operation, by copying it from an earlier version of the `openapi.json`.
1. Add a `package_path` property of type `string` to the `Repo` object.
1. Add a `branch` property of type `string` to the `Repo` object.
1. Add a `functions_region` property of type `string` to the `Site` object.
1. Add a `cdp_enabled_contexts` property of type `array` of `string`s to the `Site` object.
1. Add a `hud_enabled` property of type `boolean` to the `Site` object.
Expand All @@ -25,4 +26,4 @@ This project uses a modified `openapi.json`. Please maintain these instructions
1. Add the various `firewall_rule_set` paths from `bitballoon-openapi`'s `openapi.json` file (NOTE: both site and account level).
1. Replace the response body of the `getAccountFirewallRuleSet` operation to use the `SiteFirewallConfig` object.
1. Replace the request body of the `updateAccountFirewallRuleSet` operation to use the `SiteFirewallConfig` object.
1. Renamed the `unpublished_rules` and `published_rules` properties to `unpublished` and `published` in the `SiteFirewallConfig` object, also in the required properties array.
1. Renamed the `unpublished_rules` and `published_rules` properties to `unpublished` and `published` in the `SiteFirewallConfig` object, also in the required properties array.
5 changes: 5 additions & 0 deletions internal/netlifyapi/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10297,6 +10297,7 @@ components:
repo_branch: repo_branch
base_rel_dir: true
private_logs: true
branch: branch
allowed_branches:
- allowed_branches
- allowed_branches
Expand Down Expand Up @@ -10351,6 +10352,8 @@ components:
type: string
public_repo:
type: boolean
branch:
type: string
repo_branch:
type: string
repo_owner_type:
Expand Down Expand Up @@ -10701,6 +10704,7 @@ components:
repo_branch: repo_branch
base_rel_dir: true
private_logs: true
branch: branch
allowed_branches:
- allowed_branches
- allowed_branches
Expand Down Expand Up @@ -10911,6 +10915,7 @@ components:
repo_branch: repo_branch
base_rel_dir: true
private_logs: true
branch: branch
allowed_branches:
- allowed_branches
- allowed_branches
Expand Down
37 changes: 37 additions & 0 deletions internal/netlifyapi/model_repo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/provider/site_build_settings_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (r *siteBuildSettingsResource) write(ctx context.Context, plan *siteBuildSe
Dir: plan.PublishDirectory.ValueStringPointer(),
FunctionsDir: plan.FunctionsDirectory.ValueStringPointer(),
StopBuilds: plan.StopBuilds.ValueBoolPointer(),
RepoBranch: plan.ProductionBranch.ValueStringPointer(),
Branch: plan.ProductionBranch.ValueStringPointer(),
AllowedBranches: allowedBranches,
SkipPrs: &skipPrs,
},
Expand Down
17 changes: 17 additions & 0 deletions internal/provider/site_build_settings_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ func TestAccSiteBuildSettings(t *testing.T) {
{
Config: `resource "netlify_site_build_settings" "example" {
site_id = "49137d35-1470-4db1-810f-c185b8381cd3"
build_command = "npm run build && true"
publish_directory = "dist/dist"
production_branch = "preview"
branch_deploy_branches = ["staging"]
}`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "site_id", "49137d35-1470-4db1-810f-c185b8381cd3"),
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "build_command", "npm run build && true"),
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "publish_directory", "dist/dist"),
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "production_branch", "preview"),
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "branch_deploy_branches.#", "1"),
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "branch_deploy_branches.0", "staging"),
),
},
{
Config: `resource "netlify_site_build_settings" "example" {
site_id = "49137d35-1470-4db1-810f-c185b8381cd3"
build_command = "npm run build"
publish_directory = "dist"
production_branch = "main"
Expand Down
14 changes: 14 additions & 0 deletions internal/provider/site_collaboration_settings_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ func TestAccSiteCollaborationSettings(t *testing.T) {
{
Config: `resource "netlify_site_collaboration_settings" "example" {
site_id = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"
netlify_drawer_in_deploy_previews = false
netlify_drawer_in_branch_deploys = false
netlify_heads_up_display = false
}`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("netlify_site_collaboration_settings.example", "site_id", "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"),
resource.TestCheckResourceAttr("netlify_site_collaboration_settings.example", "netlify_drawer_in_deploy_previews", "false"),
resource.TestCheckResourceAttr("netlify_site_collaboration_settings.example", "netlify_drawer_in_branch_deploys", "false"),
resource.TestCheckResourceAttr("netlify_site_collaboration_settings.example", "netlify_heads_up_display", "false"),
),
},
{
Config: `resource "netlify_site_collaboration_settings" "example" {
site_id = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"
netlify_drawer_in_deploy_previews = true
netlify_drawer_in_branch_deploys = true
netlify_heads_up_display = true
Expand Down
18 changes: 18 additions & 0 deletions internal/provider/site_domain_settings_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,30 @@ import (
)

func TestAccSiteDomainSettings(t *testing.T) {
// TODO: change domain and domain aliases, and wait for the certificate to update
accTest(t, []resource.TestStep{
{
Config: `resource "netlify_site_domain_settings" "example" {
site_id = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"
custom_domain = "tf-test-1.examplepetstore.com"
domain_aliases = ["tf-test-1-alias.examplepetstore.com"]
branch_deploy_custom_domain = "tf-test-12-branch.examplepetstore.com"
deploy_preview_custom_domain = "tf-test-12-dp.examplepetstore.com"
}`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "site_id", "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"),
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "custom_domain", "tf-test-1.examplepetstore.com"),
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "domain_aliases.#", "1"),
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "domain_aliases.0", "tf-test-1-alias.examplepetstore.com"),
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "branch_deploy_custom_domain", "tf-test-12-branch.examplepetstore.com"),
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "deploy_preview_custom_domain", "tf-test-12-dp.examplepetstore.com"),
),
},
{
Config: `resource "netlify_site_domain_settings" "example" {
site_id = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"
custom_domain = "tf-test-1.examplepetstore.com"
domain_aliases = ["tf-test-1-alias.examplepetstore.com"]
branch_deploy_custom_domain = "tf-test-1-branch.examplepetstore.com"
deploy_preview_custom_domain = "tf-test-1-dp.examplepetstore.com"
}`,
Expand Down
3 changes: 3 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -13141,6 +13141,9 @@
"public_repo": {
"type": "boolean"
},
"branch": {
"type": "string"
},
"repo_branch": {
"type": "string"
},
Expand Down

0 comments on commit f9fbc16

Please sign in to comment.