Skip to content

Commit

Permalink
Add update test, remove ignore_read from yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
matty-rose committed Jun 11, 2021
1 parent 409a839 commit 74419fb
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 4 deletions.
4 changes: 0 additions & 4 deletions mmv1/products/appengine/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,12 @@ overrides: !ruby/object:Overrides::ResourceOverrides
skip_delete: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
test_check_destroy: templates/terraform/custom_check_destroy/skip_delete_during_test.go.erb
properties:
networkSettings: !ruby/object:Overrides::Terraform::PropertyOverride
ignore_read: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "app_engine_service_network_settings"
primary_resource_id: 'liveapp'
vars:
service_id: "default"
network_settings.ingress_traffic_allowed: "INGRESS_TRAFFIC_ALLOWED_INTERNAL_ONLY"
bucket_name: "appengine-static-content"
# This is for copying files over
files: !ruby/object:Provider::Config::Files
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package google

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccAppEngineServiceNetworkSettings_update(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccAppEngineServiceNetworkSettings_basic(context),
},
{
ResourceName: "google_app_engine_service_network_settings.main",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAppEngineServiceNetworkSettings_update(context),
},
{
ResourceName: "google_app_engine_service_network_settings.main",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccAppEngineServiceNetworkSettings_basic(context map[string]interface{}) string {
return Nprintf(`
resource "google_storage_bucket" "bucket" {
name = "tf-test-%{random_suffix}-ae-networksettings"
}
resource "google_storage_bucket_object" "object" {
name = "hello-world.zip"
bucket = google_storage_bucket.bucket.name
source = "./test-fixtures/appengine/hello-world.zip"
}
resource "google_app_engine_standard_app_version" "app" {
version_id = "v1"
service = "app-%{random_suffix}"
delete_service_on_destroy = true
runtime = "nodejs10"
entrypoint {
shell = "node ./app.js"
}
deployment {
zip {
source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}"
}
}
env_variables = {
port = "8080"
}
}
resource "google_app_engine_service_network_settings" "main" {
service = google_app_engine_standard_app_version.app.service
network_settings {
ingress_traffic_allowed = "INGRESS_TRAFFIC_ALLOWED_ALL"
}
}`, context)
}

func testAccAppEngineServiceNetworkSettings_update(context map[string]interface{}) string {
return Nprintf(`
resource "google_storage_bucket" "bucket" {
name = "tf-test-%{random_suffix}-ae-networksettings"
}
resource "google_storage_bucket_object" "object" {
name = "hello-world.zip"
bucket = google_storage_bucket.bucket.name
source = "./test-fixtures/appengine/hello-world.zip"
}
resource "google_app_engine_standard_app_version" "app" {
version_id = "v1"
service = "app-%{random_suffix}"
delete_service_on_destroy = true
runtime = "nodejs10"
entrypoint {
shell = "node ./app.js"
}
deployment {
zip {
source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}"
}
}
env_variables = {
port = "8080"
}
}
resource "google_app_engine_service_network_settings" "main" {
service = google_app_engine_standard_app_version.app.service
network_settings {
ingress_traffic_allowed = "INGRESS_TRAFFIC_ALLOWED_INTERNAL_ONLY"
}
}`, context)
}

0 comments on commit 74419fb

Please sign in to comment.