@@ -25,6 +25,7 @@ import (
2525 "github.com/hashicorp/terraform-plugin-framework/diag"
2626 "github.com/hashicorp/terraform-plugin-framework/types"
2727 "github.com/hashicorp/terraform-plugin-testing/terraform"
28+ "github.com/hashicorp/terraform-provider-google-beta/google-beta/registry"
2829 "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
2930 transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
3031)
@@ -93,7 +94,7 @@ func ParseProjectFieldValueFramework(resourceType, fieldValue, projectSchemaFiel
9394
9495// This function isn't a test of transport.go; instead, it is used as an alternative
9596// to ReplaceVars inside tests.
96- func ReplaceVarsForFrameworkTest (prov * transport_tpg.Config , rs * terraform.ResourceState , linkTmpl string ) (string , error ) {
97+ func ReplaceVarsForFrameworkTest (config * transport_tpg.Config , rs * terraform.ResourceState , linkTmpl string ) (string , error ) {
9798 re := regexp .MustCompile ("{{([[:word:]]+)}}" )
9899 var project , region , zone string
99100
@@ -125,8 +126,13 @@ func ReplaceVarsForFrameworkTest(prov *transport_tpg.Config, rs *terraform.Resou
125126 return v
126127 }
127128
128- // Attempt to draw values from the provider
129- if f := reflect .Indirect (reflect .ValueOf (prov )).FieldByName (m ); f .IsValid () {
129+ // Draw base path values from the provider config. For other config fields, fall back to reflection.
130+ if pName , found := strings .CutSuffix (m , "BasePath" ); found {
131+ // the field will look like ComputeBasePath, but the product name will be like compute (just lowercase, no underscores)
132+ p := registry .GetProduct (strings .ToLower (pName ))
133+ return transport_tpg .BaseUrl (p , config )
134+ }
135+ if f := reflect .Indirect (reflect .ValueOf (config )).FieldByName (m ); f .IsValid () {
130136 return f .String ()
131137 }
132138
0 commit comments