diff --git a/pkg/tfbridge/provider_test.go b/pkg/tfbridge/provider_test.go index 77ec0ee14..528397714 100644 --- a/pkg/tfbridge/provider_test.go +++ b/pkg/tfbridge/provider_test.go @@ -4535,3 +4535,1087 @@ func TestPlanResourceChangeStateUpgrade(t *testing.T) { } }`) } + +func UnknownsSchema() map[string]*schemav2.Resource { + return map[string]*schemav2.Resource{ + "example_resource": { + Schema: map[string]*schemav2.Schema{ + "set_prop": { + Type: schema.TypeSet, + Optional: true, + Elem: &schemav2.Schema{Type: schemav2.TypeString}, + }, + "set_block_prop": { + Type: schema.TypeSet, + Optional: true, + Elem: &schemav2.Resource{ + Schema: map[string]*schemav2.Schema{ + "prop": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + "string_prop": { + Type: schema.TypeString, + Optional: true, + }, + "list_prop": { + Type: schema.TypeList, + Optional: true, + Elem: &schemav2.Schema{Type: schemav2.TypeString}, + }, + "list_block_prop": { + Type: schema.TypeList, + Optional: true, + Elem: &schemav2.Resource{ + Schema: map[string]*schemav2.Schema{ + "prop": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + "nested_list_prop": { + Type: schema.TypeList, + Optional: true, + Elem: &schemav2.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schemav2.Schema{Type: schemav2.TypeString}, + }, + }, + "nested_list_block_prop": { + Type: schema.TypeList, + Optional: true, + Elem: &schemav2.Resource{ + Schema: map[string]*schemav2.Schema{ + "nested_prop": { + Type: schema.TypeList, + Optional: true, + Elem: &schemav2.Resource{ + Schema: map[string]*schemav2.Schema{ + "prop": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + }, + "max_items_one_prop": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schemav2.Schema{Type: schemav2.TypeString}, + }, + "max_items_one_block_prop": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schemav2.Resource{ + Schema: map[string]*schemav2.Schema{ + "prop": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + } +} + +func TestUnknowns(t *testing.T) { + // Related to [pulumi/pulumi-terraform-bridge#1885] + // This test is to ensure that we can handle unknowns in the schema. + // Note that the behaviour here might not match TF and can NOT match TF completely + // as HCL has no way of expressing unknown blocks. + // We currently have a workaround in makeTerraformInputs where we convert unknown blocks + // to blocks of unknown. + // + // The structure is that for each property we inject an unknown at every level. + // For the block tests: + // _subprop is an unknown for the subproperty in the block object + // _prop is an unknown for the whole block + // _collection is an unknown for the whole collection + // The nested match the above convention but also iterate over the nested object. + + p := &schemav2.Provider{ + Schema: map[string]*schemav2.Schema{}, + ResourcesMap: UnknownsSchema(), + } + shimProv := shimv2.NewProvider(p, shimv2.WithPlanResourceChange(func(tfResourceType string) bool { return false })) + provider := &Provider{ + tf: shimProv, + config: shimv2.NewSchemaMap(p.Schema), + info: ProviderInfo{ + P: shimProv, + ResourcePrefix: "example", + Resources: map[string]*ResourceInfo{ + "example_resource": {Tok: "ExampleResource"}, + }, + }, + } + provider.initResourceMaps() + + t.Run("unknown for string prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "stringProp":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"" + } + } + }`) + }) + + t.Run("unknown for set prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "setProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"" + } + } + }`) + }) + + t.Run("unknown for set block prop subprop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "setBlockProps":[{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"" + } + } + }`) + }) + + t.Run("unknown for set block prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "setBlockProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"" + } + } + }`) + }) + + t.Run("unknown for set block prop collection", func(t *testing.T) { + // TODO[pulumi/pulumi-terraform-bridge#1885] + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "setBlockProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"", + "setBlockProps":[{"prop":""}] + } + } + }`) + }) + + t.Run("unknown for list prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "listProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id": "" + } + } + }`) + }) + + t.Run("unknown for list block prop subprop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "listBlockProps":[{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"", + "listBlockProps":[{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}] + } + } + }`) + }) + + t.Run("unknown for list block prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "listBlockProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"" + } + } + }`) + }) + + t.Run("unknown for list block prop collection", func(t *testing.T) { + // TODO[pulumi/pulumi-terraform-bridge#1885] + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "listBlockProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"", + "listBlockProps":[null] + } + } + }`) + }) + + t.Run("unknown for nested list prop", func(t *testing.T) { + // The unknownness gets promoted one level up. This seems to be TF behaviour, independent of PRC. + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListProps":[["04da6b54-80e4-46f7-96ec-b56ff0331ba9"]] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"", + "nestedListProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + } + } + }`) + }) + + t.Run("unknown for nested list block prop nested subprop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":[{"nestedProps":[{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}]}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"", + "nestedListBlockProps":[{"nestedProps":[{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}]}] + } + } + }`) + }) + + t.Run("unknown for nested list block nested prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":[{"nestedProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"]}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"", + "nestedListBlockProps":[{"nestedProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}] + } + } + }`) + }) + + t.Run("unknown for nested list block prop nested collection", func(t *testing.T) { + // TODO[pulumi/pulumi-terraform-bridge#1885] + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":[{"nestedProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"", + "nestedListBlockProps":[{"nestedProps":[null]}] + } + } + }`) + }) + + t.Run("unknown for nested list block prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"" + } + } + }`) + }) + + t.Run("unknown for nested list block prop collection", func(t *testing.T) { + // TODO[pulumi/pulumi-terraform-bridge#1885] + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"", + "nestedListBlockProps":[null] + } + } + }`) + }) + + t.Run("unknown for max items one prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "maxItemsOneProp":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"" + } + } + }`) + }) + + t.Run("unknown for max items one block prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "maxItemsOneBlockProp":{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"} + }, + "preview":true + }, + "response": { + "properties":{ + "id":"", + "maxItemsOneBlockProp": {"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"} + } + } + }`) + }) + + t.Run("unknown for max items one block", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "maxItemsOneBlockProp":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"" + } + } + }`) + }) +} + +func TestPlanResourceChangeUnknowns(t *testing.T) { + // Related to [pulumi/pulumi-terraform-bridge#1885] + // This test is to ensure that we can handle unknowns in the schema. + // Note that the behaviour here might not match TF and can NOT match TF completely + // as HCL has no way of expressing unknown blocks. + // We currently have a workaround in makeTerraformInputs where we convert unknown blocks + // to blocks of unknown. + // + // The structure is that for each property we inject an unknown at every level. + // For the block tests: + // _subprop is an unknown for the subproperty in the block object + // _prop is an unknown for the whole block + // _collection is an unknown for the whole collection + // The nested match the above convention but also iterate over the nested object. + + p := &schemav2.Provider{ + Schema: map[string]*schemav2.Schema{}, + ResourcesMap: UnknownsSchema(), + } + shimProv := shimv2.NewProvider(p, shimv2.WithPlanResourceChange(func(tfResourceType string) bool { return true })) + provider := &Provider{ + tf: shimProv, + config: shimv2.NewSchemaMap(p.Schema), + info: ProviderInfo{ + P: shimProv, + ResourcePrefix: "example", + Resources: map[string]*ResourceInfo{ + "example_resource": {Tok: "ExampleResource"}, + }, + }, + } + provider.initResourceMaps() + + t.Run("unknown for string prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "string_prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for set prop", func(t *testing.T) { + // The unknownness gets promoted one level up. This seems to be TF behaviour, independent of PRC. + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "setProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for set block prop subprop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "setBlockProps":[{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[{ + "prop": "04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for set block prop", func(t *testing.T) { + // TODO[pulumi/pulumi-terraform-bridge#1885] + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "setBlockProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[{"prop":""}], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for set block prop collection", func(t *testing.T) { + // TODO[pulumi/pulumi-terraform-bridge#1885] + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "setBlockProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[{"prop":""}], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for list prop", func(t *testing.T) { + // The unknownness gets promoted one level up. This seems to be TF behaviour, independent of PRC. + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "listProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "maxItemsOneProp":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for list block prop subprop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "listBlockProps":[{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[{ + "prop": "04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for list block prop", func(t *testing.T) { + // The unknownness gets promoted one level up. This seems to be TF behaviour, independent of PRC. + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "listBlockProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for list block prop collection", func(t *testing.T) { + // TODO[pulumi/pulumi-terraform-bridge#1885] + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "listBlockProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[{ "prop": null }], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for nested list prop", func(t *testing.T) { + // The unknownness gets promoted one level up. This seems to be TF behaviour, independent of PRC. + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListProps":[["04da6b54-80e4-46f7-96ec-b56ff0331ba9"]] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "maxItemsOneProp":null, + "nestedListProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"], + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for nested list block prop nested subprop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":[{"nestedProps":[{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}]}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[{ + "nestedProps": [ + {"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"} + ] + }], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for nested list block prop nested prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":[{"nestedProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"]}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[{ + "nestedProps": "04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for nested list block prop nested collection", func(t *testing.T) { + // TODO[pulumi/pulumi-terraform-bridge#1885] + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":[{"nestedProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"}] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[{ + "nestedProps": [{"prop":null}] + }], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for nested list block prop", func(t *testing.T) { + // The unknownness gets promoted one level up. This seems to be TF behaviour, independent of PRC. + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":["04da6b54-80e4-46f7-96ec-b56ff0331ba9"] + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for nested list block collection", func(t *testing.T) { + // TODO[pulumi/pulumi-terraform-bridge#1885] + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "nestedListBlockProps":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[{"nestedProps":null}], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for max items one prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "maxItemsOneProp":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":null + } + } + }`) + }) + + t.Run("unknown for max items one block subprop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "maxItemsOneBlockProp":{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"} + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":{"prop":"04da6b54-80e4-46f7-96ec-b56ff0331ba9"} + } + } + }`) + }) + + t.Run("unknown for max items one block prop", func(t *testing.T) { + testutils.Replay(t, provider, ` + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:dev::teststack::ExampleResource::exres", + "properties":{ + "__defaults":[], + "maxItemsOneBlockProp":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + }, + "preview":true + }, + "response": { + "properties":{ + "id":"04da6b54-80e4-46f7-96ec-b56ff0331ba9", + "stringProp":null, + "setProps":null, + "listProps":null, + "nestedListProps":null, + "maxItemsOneProp":null, + "setBlockProps":[], + "listBlockProps":[], + "nestedListBlockProps":[], + "maxItemsOneBlockProp":"04da6b54-80e4-46f7-96ec-b56ff0331ba9" + } + } + }`) + }) +}