@@ -16,54 +16,57 @@ import (
1616 "gopkg.in/yaml.v3"
1717
1818 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/pulcheck"
19+ "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
1920)
2021
2122func TestFullyComputedNestedAttribute (t * testing.T ) {
2223 t .Parallel ()
23- resMap := map [string ]* schema.Resource {
24- "prov_test" : {
25- Schema : map [string ]* schema.Schema {
26- "attached_disks" : {
27- Type : schema .TypeList ,
28- Optional : true ,
29- Elem : & schema.Resource {
30- Schema : map [string ]* schema.Schema {
31- "name" : {
32- Optional : true ,
33- Type : schema .TypeString ,
34- },
35- "key256" : {
36- Computed : true ,
37- Type : schema .TypeString ,
24+
25+ bridgedProvider := func (importVal any ) info.Provider {
26+ return pulcheck .BridgedProvider (t , "prov" , & schema.Provider {
27+ ResourcesMap : map [string ]* schema.Resource {
28+ "prov_test" : {
29+ Schema : map [string ]* schema.Schema {
30+ "attached_disks" : {
31+ Type : schema .TypeList ,
32+ Optional : true ,
33+ Elem : & schema.Resource {
34+ Schema : map [string ]* schema.Schema {
35+ "name" : {
36+ Optional : true ,
37+ Type : schema .TypeString ,
38+ },
39+ "key256" : {
40+ Computed : true ,
41+ Type : schema .TypeString ,
42+ },
43+ },
3844 },
3945 },
46+ "top_level_computed" : {
47+ Type : schema .TypeString ,
48+ Computed : true ,
49+ },
4050 },
41- },
42- "top_level_computed" : {
43- Type : schema .TypeString ,
44- Computed : true ,
45- },
46- },
47- },
48- }
49-
50- importer := func (val any ) func (context.Context , * schema.ResourceData , interface {}) ([]* schema.ResourceData , error ) {
51- return func (ctx context.Context , rd * schema.ResourceData , i interface {}) ([]* schema.ResourceData , error ) {
52- elMap := map [string ]any {
53- "name" : "disk1" ,
54- "key256" : val ,
55- }
56- err := rd .Set ("attached_disks" , []map [string ]any {elMap })
57- require .NoError (t , err )
51+ Importer : & schema.ResourceImporter {
52+ StateContext : func (ctx context.Context , rd * schema.ResourceData , i interface {}) ([]* schema.ResourceData , error ) {
53+ elMap := map [string ]any {
54+ "name" : "disk1" ,
55+ "key256" : importVal ,
56+ }
57+ err := rd .Set ("attached_disks" , []map [string ]any {elMap })
58+ require .NoError (t , err )
5859
59- err = rd .Set ("top_level_computed" , "computed_val" )
60- require .NoError (t , err )
60+ err = rd .Set ("top_level_computed" , "computed_val" )
61+ require .NoError (t , err )
6162
62- return []* schema.ResourceData {rd }, nil
63- }
63+ return []* schema.ResourceData {rd }, nil
64+ },
65+ },
66+ },
67+ },
68+ })
6469 }
65- tfp := & schema.Provider {ResourcesMap : resMap }
66- bridgedProvider := pulcheck .BridgedProvider (t , "prov" , tfp )
6770
6871 program := `
6972name: test
@@ -83,9 +86,7 @@ runtime: yaml
8386 },
8487 } {
8588 t .Run (tc .name , func (t * testing.T ) {
86- resMap ["prov_test" ].Importer = & schema.ResourceImporter {
87- StateContext : importer (tc .importVal ),
88- }
89+ bridgedProvider := bridgedProvider (tc .importVal )
8990
9091 pt := pulcheck .PulCheck (t , bridgedProvider , program )
9192
0 commit comments