@@ -32,12 +32,12 @@ import (
3232
3333// MakeCreate is a helper function for calling [Create] in [testing.T.Run] subcases.
3434func MakeCreate (
35- resource map [string ]* schema.Schema , tfConfig cty.Value , puConfig resource. PropertyMap ,
35+ resource map [string ]* schema.Schema , tfConfig cty.Value ,
3636 options ... CreateOption ,
3737) func (t * testing.T ) {
3838 return func (t * testing.T ) {
3939 t .Parallel ()
40- Create (t , resource , tfConfig , puConfig , options ... )
40+ Create (t , resource , tfConfig , options ... )
4141 }
4242}
4343
@@ -51,7 +51,7 @@ func MakeCreate(
5151//
5252// Create *does not* verify the outputs of the resource, only that the provider witnessed the same inputs.
5353func Create (
54- t T , resource map [string ]* schema.Schema , tfConfig cty.Value , puConfig resource. PropertyMap ,
54+ t T , resourceSchema map [string ]* schema.Schema , tfConfig cty.Value ,
5555 options ... CreateOption ,
5656) {
5757
@@ -60,9 +60,12 @@ func Create(
6060 f (& opts )
6161 }
6262
63- if isInferPulumiMarker (puConfig ) {
63+ var puConfig resource.PropertyMap
64+ if opts .puConfig != nil {
65+ puConfig = * opts .puConfig
66+ } else {
6467 puConfig = inferPulumiValue (t ,
65- shimv2 .NewSchemaMap (resource ),
68+ shimv2 .NewSchemaMap (resourceSchema ),
6669 opts .resourceInfo .GetFields (),
6770 tfConfig ,
6871 )
@@ -77,7 +80,7 @@ func Create(
7780
7881 makeResource := func (writeTo * result ) * schema.Resource {
7982 return & schema.Resource {
80- Schema : resource ,
83+ Schema : resourceSchema ,
8184 SchemaVersion : opts .stateUpgrader .schemaVersion ,
8285 StateUpgraders : opts .stateUpgrader .stateUpgraders ,
8386 Timeouts : opts .timeouts ,
@@ -91,7 +94,7 @@ func Create(
9194
9295 tfwd := t .TempDir ()
9396 tfd := newTFResDriver (t , tfwd , defProviderShortName , defRtype , makeResource (& tfResult ))
94- tfd .writePlanApply (t , resource , defRtype , "example" , tfConfig , lifecycleArgs {})
97+ tfd .writePlanApply (t , resourceSchema , defRtype , "example" , tfConfig , lifecycleArgs {})
9598
9699 require .True (t , tfResult .wasSet , "terraform test result was not set" )
97100
@@ -119,13 +122,14 @@ func Create(
119122 assert .Equal (t , tfResult .meta , puResult .meta ,
120123 "assert that both providers were configured with the same provider metadata" )
121124
122- assertResourceDataEqual (t , resource , tfResult .data , puResult .data )
125+ assertResourceDataEqual (t , resourceSchema , tfResult .data , puResult .data )
123126}
124127
125128type createOpts struct {
126129 resourceInfo * info.Resource
127130 stateUpgrader createOptsUpgraders
128131 timeouts * schema.ResourceTimeout
132+ puConfig * resource.PropertyMap
129133}
130134
131135type createOptsUpgraders struct {
@@ -153,3 +157,8 @@ func CreateStateUpgrader(schemaVersion int, upgraders []schema.StateUpgrader) Cr
153157func CreateTimeout (timeouts * schema.ResourceTimeout ) CreateOption {
154158 return func (o * createOpts ) { o .timeouts = timeouts }
155159}
160+
161+ // CreatePulumiConfig specifies an explicit config value in Pulumi's value space.
162+ func CreatePulumiConfig (config resource.PropertyMap ) CreateOption {
163+ return func (o * createOpts ) { o .puConfig = & config }
164+ }
0 commit comments