Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
magodo committed Sep 15, 2022
1 parent 77970c3 commit 2080339
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"version": 4,
"terraform_version": "1.1.2",
"serial": 6,
"lineage": "a413b82a-0d96-28b6-aede-00cac5a6eb69",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "azurerm_resource_group",
"name": "a",
"provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "/subscriptions/REDACTED/resourceGroups/foo",
"location": "eastus2",
"name": "foo",
"tags": null,
"timeouts": null
},
"sensitive_attributes": [],
"private": "REDACTED"
}
]
},
{
"mode": "managed",
"type": "azurerm_resource_group",
"name": "with_invalid_attr",
"provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "/subscriptions/REDACTED/resourceGroups/bar",
"location": "eastus2",
"name": "bar",
"tags": null,
"invalid": 123,
"timeouts": null
},
"sensitive_attributes": [],
"private": "REDACTED"
}
]
}
]
}
16 changes: 14 additions & 2 deletions tfadd/tfadd_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,22 @@ resource "azurerm_resource_group" "b" {
Target("azurerm_resource_group.b"),
Target("azurerm_resource_group.a"),
},
expect: `resource "azurerm_resource_group" "b" {
expect: `resource "azurerm_resource_group" "a" {
location = "eastus2"
name = "foo"
}
resource "azurerm_resource_group" "b" {
location = "eastus2"
name = "bar"
}
resource "azurerm_resource_group" "a" {
`,
},
// See: https://github.com/Azure/aztfy/issues/215
{
name: "generate one resource from a state that has resource contains unsupported attribute of the provider",
statefile: "azurerm_resource_groups_with_unsupported_attribute",
options: []StateOption{Target("azurerm_resource_group.a")},
expect: `resource "azurerm_resource_group" "a" {
location = "eastus2"
name = "foo"
}
Expand Down Expand Up @@ -158,6 +169,7 @@ resource "azurerm_resource_group" "b" {
require.Regexp(t, tt.expectError, err.Error())
return
}
require.NoError(t, err)
require.Equal(t, tt.expect, string(b))
})
}
Expand Down

0 comments on commit 2080339

Please sign in to comment.