MCPcopy
hub / github.com/Azure/aztfexport / TestConfigInfos_PopulateRelationDeps

Function TestConfigInfos_PopulateRelationDeps

internal/meta/config_info_test.go:296–382  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

294}
295
296func TestConfigInfos_PopulateRelationDeps(t *testing.T) {
297 testCases := []struct {
298 name string
299 inputConfigs ConfigInfos
300 expectedRelationDep map[string]*Dependency // key: AzureResourceId
301 }{
302 {
303 name: "no parent-child relationships",
304 inputConfigs: []ConfigInfo{
305 newConfigInfo(
306 "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Foo/foo/foo1",
307 "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Foo/foo/foo1",
308 "azurerm_foo_resource.res-0",
309 `
310resource "azurerm_foo_resource" "res-0" {
311 name = "foo1"
312}
313`,
314 nil,
315 ),
316 newConfigInfo(
317 "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Bar/bar/bar1",
318 "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Bar/bar/bar1",
319 "azurerm_bar_resource.res-1",
320 `
321resource "azurerm_bar_resource" "res-1" {
322 name = "bar1"
323}
324`,
325 nil,
326 ),
327 },
328 expectedRelationDep: map[string]*Dependency{
329 "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Foo/foo/foo1": nil,
330 "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Bar/bar/bar1": nil,
331 },
332 },
333 {
334 name: "res-0 is a parent of res-1: expect explicit dep from res-1 to res-0",
335 inputConfigs: []ConfigInfo{
336 newConfigInfo(
337 "/subscriptions/123/resourceGroups/rg1",
338 "/subscriptions/123/resourceGroups/rg1",
339 "azurerm_resource_group.res-0",
340 `
341resource "azurerm_resource_group" "res-0" {
342 name = "rg1"
343 location = "West Europe"
344}
345`,
346 nil,
347 ),
348 newConfigInfo(
349 "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Foo/foo/foo1",
350 "/subscriptions/123/resourceGroups/rg1/providers/Microsoft.Foo/foo/foo1",
351 "azurerm_foo_resource.res-1",
352 `
353resource "azurerm_foo_resource" "res-1" {

Callers

nothing calls this directly

Calls 4

newConfigInfoFunction · 0.85
mustParseTFAddrFunction · 0.85
PopulateRelationDepsMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected