Skip to content

Commit f9fbc16

Browse files
committed
site settings test updates
1 parent 9074bf9 commit f9fbc16

9 files changed

+98
-3
lines changed

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ openapi_generate: ## Generate the go code from the OpenAPI spec.
2525
-o /local/internal/netlifyapi ; \
2626
sed -i '' 's/int32/int64/g' internal/netlifyapi/model_*.go ; \
2727
sed -i '' 's/int32/int64/g' internal/netlifyapi/api_*.go ; \
28-
sed -i '' 's/return e.error/return fmt.Sprintf("%s: %q", e.error, e.body)/g' internal/netlifyapi/client.go
28+
sed -i '' 's/return e.error/return fmt.Sprintf("%s: %s", e.error, e.body)/g' internal/netlifyapi/client.go
2929

3030
test: ## Test the go code.
3131
go test -v ./...

UPDATING_OPENAPI_JSON.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This project uses a modified `openapi.json`. Please maintain these instructions
1212
1. Remove the `values`, `scopes` and `is_secret` parameters from the `updateEnvVar` operation.
1313
1. Add a request body schema to the `updateEnvVar` operation, by copying it from an earlier version of the `openapi.json`.
1414
1. Add a `package_path` property of type `string` to the `Repo` object.
15+
1. Add a `branch` property of type `string` to the `Repo` object.
1516
1. Add a `functions_region` property of type `string` to the `Site` object.
1617
1. Add a `cdp_enabled_contexts` property of type `array` of `string`s to the `Site` object.
1718
1. Add a `hud_enabled` property of type `boolean` to the `Site` object.
@@ -25,4 +26,4 @@ This project uses a modified `openapi.json`. Please maintain these instructions
2526
1. Add the various `firewall_rule_set` paths from `bitballoon-openapi`'s `openapi.json` file (NOTE: both site and account level).
2627
1. Replace the response body of the `getAccountFirewallRuleSet` operation to use the `SiteFirewallConfig` object.
2728
1. Replace the request body of the `updateAccountFirewallRuleSet` operation to use the `SiteFirewallConfig` object.
28-
1. Renamed the `unpublished_rules` and `published_rules` properties to `unpublished` and `published` in the `SiteFirewallConfig` object, also in the required properties array.
29+
1. Renamed the `unpublished_rules` and `published_rules` properties to `unpublished` and `published` in the `SiteFirewallConfig` object, also in the required properties array.

internal/netlifyapi/api/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10297,6 +10297,7 @@ components:
1029710297
repo_branch: repo_branch
1029810298
base_rel_dir: true
1029910299
private_logs: true
10300+
branch: branch
1030010301
allowed_branches:
1030110302
- allowed_branches
1030210303
- allowed_branches
@@ -10351,6 +10352,8 @@ components:
1035110352
type: string
1035210353
public_repo:
1035310354
type: boolean
10355+
branch:
10356+
type: string
1035410357
repo_branch:
1035510358
type: string
1035610359
repo_owner_type:
@@ -10701,6 +10704,7 @@ components:
1070110704
repo_branch: repo_branch
1070210705
base_rel_dir: true
1070310706
private_logs: true
10707+
branch: branch
1070410708
allowed_branches:
1070510709
- allowed_branches
1070610710
- allowed_branches
@@ -10911,6 +10915,7 @@ components:
1091110915
repo_branch: repo_branch
1091210916
base_rel_dir: true
1091310917
private_logs: true
10918+
branch: branch
1091410919
allowed_branches:
1091510920
- allowed_branches
1091610921
- allowed_branches

internal/netlifyapi/model_repo.go

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/provider/site_build_settings_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func (r *siteBuildSettingsResource) write(ctx context.Context, plan *siteBuildSe
311311
Dir: plan.PublishDirectory.ValueStringPointer(),
312312
FunctionsDir: plan.FunctionsDirectory.ValueStringPointer(),
313313
StopBuilds: plan.StopBuilds.ValueBoolPointer(),
314-
RepoBranch: plan.ProductionBranch.ValueStringPointer(),
314+
Branch: plan.ProductionBranch.ValueStringPointer(),
315315
AllowedBranches: allowedBranches,
316316
SkipPrs: &skipPrs,
317317
},

internal/provider/site_build_settings_resource_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ func TestAccSiteBuildSettings(t *testing.T) {
1212
{
1313
Config: `resource "netlify_site_build_settings" "example" {
1414
site_id = "49137d35-1470-4db1-810f-c185b8381cd3"
15+
build_command = "npm run build && true"
16+
publish_directory = "dist/dist"
17+
production_branch = "preview"
18+
branch_deploy_branches = ["staging"]
19+
}`,
20+
Check: resource.ComposeAggregateTestCheckFunc(
21+
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "site_id", "49137d35-1470-4db1-810f-c185b8381cd3"),
22+
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "build_command", "npm run build && true"),
23+
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "publish_directory", "dist/dist"),
24+
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "production_branch", "preview"),
25+
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "branch_deploy_branches.#", "1"),
26+
resource.TestCheckResourceAttr("netlify_site_build_settings.example", "branch_deploy_branches.0", "staging"),
27+
),
28+
},
29+
{
30+
Config: `resource "netlify_site_build_settings" "example" {
31+
site_id = "49137d35-1470-4db1-810f-c185b8381cd3"
1532
build_command = "npm run build"
1633
publish_directory = "dist"
1734
production_branch = "main"

internal/provider/site_collaboration_settings_resource_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ func TestAccSiteCollaborationSettings(t *testing.T) {
1212
{
1313
Config: `resource "netlify_site_collaboration_settings" "example" {
1414
site_id = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"
15+
netlify_drawer_in_deploy_previews = false
16+
netlify_drawer_in_branch_deploys = false
17+
netlify_heads_up_display = false
18+
}`,
19+
Check: resource.ComposeAggregateTestCheckFunc(
20+
resource.TestCheckResourceAttr("netlify_site_collaboration_settings.example", "site_id", "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"),
21+
resource.TestCheckResourceAttr("netlify_site_collaboration_settings.example", "netlify_drawer_in_deploy_previews", "false"),
22+
resource.TestCheckResourceAttr("netlify_site_collaboration_settings.example", "netlify_drawer_in_branch_deploys", "false"),
23+
resource.TestCheckResourceAttr("netlify_site_collaboration_settings.example", "netlify_heads_up_display", "false"),
24+
),
25+
},
26+
{
27+
Config: `resource "netlify_site_collaboration_settings" "example" {
28+
site_id = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"
1529
netlify_drawer_in_deploy_previews = true
1630
netlify_drawer_in_branch_deploys = true
1731
netlify_heads_up_display = true

internal/provider/site_domain_settings_resource_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,30 @@ import (
88
)
99

1010
func TestAccSiteDomainSettings(t *testing.T) {
11+
// TODO: change domain and domain aliases, and wait for the certificate to update
1112
accTest(t, []resource.TestStep{
1213
{
1314
Config: `resource "netlify_site_domain_settings" "example" {
1415
site_id = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"
1516
custom_domain = "tf-test-1.examplepetstore.com"
1617
domain_aliases = ["tf-test-1-alias.examplepetstore.com"]
18+
branch_deploy_custom_domain = "tf-test-12-branch.examplepetstore.com"
19+
deploy_preview_custom_domain = "tf-test-12-dp.examplepetstore.com"
20+
}`,
21+
Check: resource.ComposeAggregateTestCheckFunc(
22+
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "site_id", "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"),
23+
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "custom_domain", "tf-test-1.examplepetstore.com"),
24+
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "domain_aliases.#", "1"),
25+
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "domain_aliases.0", "tf-test-1-alias.examplepetstore.com"),
26+
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "branch_deploy_custom_domain", "tf-test-12-branch.examplepetstore.com"),
27+
resource.TestCheckResourceAttr("netlify_site_domain_settings.example", "deploy_preview_custom_domain", "tf-test-12-dp.examplepetstore.com"),
28+
),
29+
},
30+
{
31+
Config: `resource "netlify_site_domain_settings" "example" {
32+
site_id = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"
33+
custom_domain = "tf-test-1.examplepetstore.com"
34+
domain_aliases = ["tf-test-1-alias.examplepetstore.com"]
1735
branch_deploy_custom_domain = "tf-test-1-branch.examplepetstore.com"
1836
deploy_preview_custom_domain = "tf-test-1-dp.examplepetstore.com"
1937
}`,

openapi.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13141,6 +13141,9 @@
1314113141
"public_repo": {
1314213142
"type": "boolean"
1314313143
},
13144+
"branch": {
13145+
"type": "string"
13146+
},
1314413147
"repo_branch": {
1314513148
"type": "string"
1314613149
},

0 commit comments

Comments
 (0)