Skip to content

Commit 121a8bc

Browse files
committed
Add an empty override block unit test
1 parent 372a892 commit 121a8bc

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

override_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,24 @@ func TestMergeBlock(t *testing.T) {
288288
// Attribute should still be overridden.
289289
assert.Equal(t, "99", attrValue(t, primary.Body().Attributes(), "x"))
290290
})
291+
292+
t.Run("EmptyOverride", func(t *testing.T) {
293+
t.Parallel()
294+
primary := parseBlock(t, `resource "a" "b" {
295+
x = 1
296+
nested {
297+
y = 2
298+
}
299+
}`)
300+
override := parseBlock(t, `resource "a" "b" {}`)
301+
mergeBlock(primary, override)
302+
303+
// Nothing should change — attributes and blocks preserved.
304+
assert.Equal(t, "1", attrValue(t, primary.Body().Attributes(), "x"))
305+
blocks := primary.Body().Blocks()
306+
require.Len(t, blocks, 1)
307+
assert.Equal(t, "nested", blocks[0].Type())
308+
})
291309
}
292310

293311
// readFile reads a file from an fs.FS using Open+Read (since overrideFS

0 commit comments

Comments
 (0)