Skip to content
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

Add Cloud Run v2 Service urls field #12194

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mmv1/products/cloudrunv2/Service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,13 @@ properties:
description: |
The main URI in which this Service is serving traffic.
output: true
- name: 'urls'
type: Array
item_type:
type: String
description: |-
All URLs serving traffic for this Service.
output: true
- name: 'reconciling'
type: Boolean
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cloudrunv2_test

import (
"fmt"
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
Expand All @@ -17,6 +18,10 @@ func TestAccDataSourceGoogleCloudRunV2Service_basic(t *testing.T) {
name := fmt.Sprintf("tf-test-cloud-run-v2-service-%d", acctest.RandInt(t))
location := "us-central1"
id := fmt.Sprintf("projects/%s/locations/%s/services/%s", project, location, name)
deterministicURLRegex, err := regexp.Compile(fmt.Sprintf("https://%s-[0-9]+.%s.run.ap", name, location))
if err != nil {
t.Fatalf("Failed to compile deterministic URL regex: %v", err)
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
Expand All @@ -28,6 +33,8 @@ func TestAccDataSourceGoogleCloudRunV2Service_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.google_cloud_run_v2_service.hello", "id", id),
resource.TestCheckResourceAttr("data.google_cloud_run_v2_service.hello", "name", name),
resource.TestCheckResourceAttr("data.google_cloud_run_v2_service.hello", "location", location),
resource.TestCheckResourceAttr("data.google_cloud_run_v2_service.hello", "urls.#", "2"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given these are output fields, I don't believe they need to be verified in a test like this. is there a reason you added these I'm not realizing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://googlecloudplatform.github.io/magic-modules/contribute/review-pr/: "all fields added/updated in the PR appear in at least one test". If this is not meant to apply to output only fields I wasn't able to find where this is stated.

resource.TestMatchResourceAttr("data.google_cloud_run_v2_service.hello", "urls.0", deterministicURLRegex),
),
},
},
Expand Down
Loading