Skip to content

Commit 80e01d1

Browse files
committed
test(terraform): add failing unit test with ambition to resolve
Module counts are incorrectly being handled
1 parent 5fd0a76 commit 80e01d1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

pkg/iac/scanners/terraform/parser/parser_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,32 @@ output "set_count" {
18001800
assert.Len(t, datas, 2)
18011801
}
18021802

1803+
func TestBlockCountModules(t *testing.T) {
1804+
t.Skip("This test is currently failing, the 'count = 0' module 'bar' is still loaded")
1805+
// `count` meta attributes are incorrectly handled when referencing
1806+
// a module output.
1807+
files := map[string]string{
1808+
"main.tf": `
1809+
module "foo" {
1810+
source = "./modules/foo"
1811+
}
1812+
1813+
module "bar" {
1814+
source = "./modules/foo"
1815+
count = module.foo.staticZero
1816+
}
1817+
`,
1818+
"modules/foo/main.tf": `
1819+
output "staticZero" {
1820+
value = 0
1821+
}
1822+
`,
1823+
}
1824+
1825+
modules := parse(t, files)
1826+
require.Len(t, modules, 2)
1827+
}
1828+
18031829
// TestNestedModulesOptions ensures parser options are carried to the nested
18041830
// submodule evaluators.
18051831
// The test will include an invalid module that will fail to download

0 commit comments

Comments
 (0)