(t *testing.T)
| 39 | } |
| 40 | |
| 41 | func TestConfigInfos_PopulateReferenceDeps(t *testing.T) { |
| 42 | testCases := []struct { |
| 43 | name string |
| 44 | inputConfigs ConfigInfos |
| 45 | expectedRgNameReferenceDeps map[string]*Dependency // key: AzureResourceId |
| 46 | expectedIdReferenceDeps map[string]map[string]Dependency // key: AzureResourceId, inner key: TFResourceId |
| 47 | expectedIdReferenceAmbiguousDeps map[string]map[string][]Dependency // key: AzureResourceId, inner key: TFResourceId |
| 48 | }{ |
| 49 | { |
| 50 | name: "no dependencies between resources", |
| 51 | inputConfigs: []ConfigInfo{ |
| 52 | newConfigInfo( |
| 53 | "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Foo/foo/foo1", |
| 54 | "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Foo/foo/foo1", |
| 55 | "azurerm_foo_resource.res-0", |
| 56 | ` |
| 57 | resource "azurerm_foo_resource" "res-0" { |
| 58 | name = "foo1" |
| 59 | } |
| 60 | `, |
| 61 | nil, |
| 62 | ), |
| 63 | newConfigInfo( |
| 64 | "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Bar/bar/bar1", |
| 65 | "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Bar/bar/bar1", |
| 66 | "azurerm_bar_resource.res-1", |
| 67 | ` |
| 68 | resource "azurerm_bar_resource" "res-1" { |
| 69 | name = "bar1" |
| 70 | } |
| 71 | `, |
| 72 | nil, |
| 73 | ), |
| 74 | }, |
| 75 | expectedIdReferenceDeps: map[string]map[string]Dependency{ |
| 76 | "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Foo/foo/foo1": {}, |
| 77 | "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Bar/bar/bar1": {}, |
| 78 | }, |
| 79 | expectedIdReferenceAmbiguousDeps: map[string]map[string][]Dependency{ |
| 80 | "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Foo/foo/foo1": {}, |
| 81 | "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Bar/bar/bar1": {}, |
| 82 | }, |
| 83 | }, |
| 84 | { |
| 85 | name: "res-1 reference res-2 by id", |
| 86 | inputConfigs: []ConfigInfo{ |
| 87 | newConfigInfo( |
| 88 | "/subscriptions/123/resourceGroups/rg1", |
| 89 | "/subscriptions/123/resourceGroups/rg1", |
| 90 | "azurerm_resource_group.res-0", |
| 91 | ` |
| 92 | resource "azurerm_resource_group" "res-0" { |
| 93 | name = "rg1" |
| 94 | location = "West Europe" |
| 95 | } |
| 96 | `, |
| 97 | nil, |
| 98 | ), |
nothing calls this directly
no test coverage detected