Skip to content

Commit

Permalink
Add test for lists as blocks (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frassle committed Dec 14, 2022
1 parent 17035a8 commit 4786bb7
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/tf2pulumi/convert/testdata/list_as_blocks/main.tf
@@ -0,0 +1,17 @@
data "blocks_data_source" "a_data_source" {
a_list_of_resources {
inner_string = "hi"
}
a_list_of_resources {
inner_string = "bye"
}
}

resource "blocks_resource" "a_resource" {
a_list_of_resources {
inner_string = "hi"
}
a_list_of_resources {
inner_string = "bye"
}
}
18 changes: 18 additions & 0 deletions pkg/tf2pulumi/convert/testdata/list_as_blocks/pcl/main.pp
@@ -0,0 +1,18 @@
aDataSource = invoke("blocks:index/index:data_source", {
aListOfResources = [
{
innerString = "hi"
},
{
innerString = "bye"
} ]
})
resource aResource "blocks:index/index:resource" {
aListOfResources = [
{
innerString = "hi"
},
{
innerString = "bye"
} ]
}
55 changes: 55 additions & 0 deletions pkg/tf2pulumi/convert/testdata/mappings/blocks.json
@@ -0,0 +1,55 @@
{
"name": "blocks",
"provider": {
"dataSources": {
"blocks_data_source": {
"a_list_of_resources": {
"type": 5,
"optional": true,
"element": {
"resource": {
"inner_string": {
"type": 4,
"optional": true
}
}
}
},
"result": {
"type": 4,
"computed": true
}
}
},
"resources": {
"blocks_resource": {
"a_list_of_resources": {
"type": 5,
"optional": true,
"element": {
"resource": {
"inner_string": {
"type": 4,
"optional": true
}
}
}
},
"result": {
"type": 4,
"computed": true
}
}
}
},
"dataSources": {
"blocks_data_source": {
"tok": "blocks:index/index:data_source"
}
},
"resources": {
"blocks_resource": {
"tok": "blocks:index/index:resource"
}
}
}
130 changes: 130 additions & 0 deletions pkg/tf2pulumi/convert/testdata/schemas/blocks.json
@@ -0,0 +1,130 @@
{
"name": "blocks",
"attribution": "This Pulumi package is based on the [`blocks` Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks).",
"meta": {
"moduleFormat": "(.*)(?:/[^/]*)"
},
"language": {
"nodejs": {
"compatibility": "tfbridge20",
"disableUnionOutputTypes": true,
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi-blocks` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-blocks` repo](https://github.com/terraform-providers/terraform-provider-blocks/issues)."
},
"python": {
"compatibility": "tfbridge20",
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi-blocks` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-blocks` repo](https://github.com/terraform-providers/terraform-provider-blocks/issues)."
}
},
"config": {},
"types": {
"blocks:index/data_sourceAListOfResource:data_sourceAListOfResource": {
"properties": {
"innerString": {
"type": "string",
"language": {
"python": {
"mapCase": false
}
}
}
},
"type": "object"
},
"blocks:index/resourceAListOfResource:resourceAListOfResource": {
"properties": {
"innerString": {
"type": "string",
"language": {
"python": {
"mapCase": false
}
}
}
},
"type": "object"
}
},
"provider": {
"description": "The provider type for the blocks package. By default, resources use package-wide configuration\nsettings, however an explicit `Provider` instance may be created and passed during resource\nconstruction to achieve fine-grained programmatic control over provider settings. See the\n[documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.\n"
},
"resources": {
"blocks:index/index:resource": {
"properties": {
"aListOfResources": {
"type": "array",
"items": {
"$ref": "#/types/blocks:index/resourceAListOfResource:resourceAListOfResource"
}
},
"result": {
"type": "string"
}
},
"required": [
"result"
],
"inputProperties": {
"aListOfResources": {
"type": "array",
"items": {
"$ref": "#/types/blocks:index/resourceAListOfResource:resourceAListOfResource"
}
}
},
"stateInputs": {
"description": "Input properties used for looking up and filtering resource resources.\n",
"properties": {
"aListOfResources": {
"type": "array",
"items": {
"$ref": "#/types/blocks:index/resourceAListOfResource:resourceAListOfResource"
}
},
"result": {
"type": "string"
}
},
"type": "object"
}
}
},
"functions": {
"blocks:index/index:data_source": {
"inputs": {
"description": "A collection of arguments for invoking data_source.\n",
"properties": {
"aListOfResources": {
"type": "array",
"items": {
"$ref": "#/types/blocks:index/data_sourceAListOfResource:data_sourceAListOfResource"
}
}
},
"type": "object"
},
"outputs": {
"description": "A collection of values returned by data_source.\n",
"properties": {
"aListOfResources": {
"type": "array",
"items": {
"$ref": "#/types/blocks:index/data_sourceAListOfResource:data_sourceAListOfResource"
}
},
"id": {
"type": "string",
"description": "The provider-assigned unique ID for this managed resource.\n"
},
"result": {
"type": "string"
}
},
"type": "object",
"required": [
"result",
"id"
]
}
}
}
}

0 comments on commit 4786bb7

Please sign in to comment.