@@ -2,6 +2,7 @@ package cloudrunv2_test
2
2
3
3
import (
4
4
"fmt"
5
+ "regexp"
5
6
"testing"
6
7
7
8
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -17,6 +18,10 @@ func TestAccDataSourceGoogleCloudRunV2Service_basic(t *testing.T) {
17
18
name := fmt .Sprintf ("tf-test-cloud-run-v2-service-%d" , acctest .RandInt (t ))
18
19
location := "us-central1"
19
20
id := fmt .Sprintf ("projects/%s/locations/%s/services/%s" , project , location , name )
21
+ deterministicURLRegex , err := regexp .Compile (fmt .Sprintf ("https://%s-[0-9]+.%s.run.ap" , name , location ))
22
+ if err != nil {
23
+ t .Fatalf ("Failed to compile deterministic URL regex: %v" , err )
24
+ }
20
25
21
26
acctest .VcrTest (t , resource.TestCase {
22
27
PreCheck : func () { acctest .AccTestPreCheck (t ) },
@@ -28,6 +33,8 @@ func TestAccDataSourceGoogleCloudRunV2Service_basic(t *testing.T) {
28
33
resource .TestCheckResourceAttr ("data.google_cloud_run_v2_service.hello" , "id" , id ),
29
34
resource .TestCheckResourceAttr ("data.google_cloud_run_v2_service.hello" , "name" , name ),
30
35
resource .TestCheckResourceAttr ("data.google_cloud_run_v2_service.hello" , "location" , location ),
36
+ resource .TestCheckResourceAttr ("data.google_cloud_run_v2_service.hello" , "urls.#" , "2" ),
37
+ resource .TestMatchResourceAttr ("data.google_cloud_run_v2_service.hello" , "urls.0" , deterministicURLRegex ),
31
38
),
32
39
},
33
40
},
0 commit comments