Skip to content

Commit 87a57e1

Browse files
committed
fix: correct ERB test expectations for trim_mode behavior
The ERB renderer uses trim_mode: "-" which has specific newline handling: - <% code %> preserves the newline after the tag - <% code -%> suppresses the newline after the tag Fixed 5 failing tests by: 1. Removing incorrect blank line expectation in 'skips block when property is missing' 2. Adding -%> to opening if tags in 4 conditional tests to suppress unwanted newlines 3. Removing leading newlines from expected output where appropriate These changes align test expectations with standard ERB behavior.
1 parent 53e323b commit 87a57e1

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

templatescompiler/erbrenderer/erb_renderer_test.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ should_not_appear: <%= host %>
274274
<% end -%>
275275
after`
276276
expectedTemplateContents = `before
277-
278277
after`
279278

280279
err := os.WriteFile(erbTemplateFilepath, []byte(erbTemplateContent), 0666)
@@ -466,10 +465,10 @@ debug: false`
466465
})
467466

468467
It("uses booleans in conditionals", func() {
469-
erbTemplateContent = `<% if p('features.enabled') %>
468+
erbTemplateContent = `<% if p('features.enabled') -%>
470469
feature is enabled
471470
<% end -%>
472-
<% if !p('features.debug_mode') %>
471+
<% if !p('features.debug_mode') -%>
473472
debug is disabled
474473
<% end -%>`
475474
expectedTemplateContents = `feature is enabled
@@ -955,14 +954,13 @@ provider_name: thales`
955954
})
956955

957956
It("checks if any element matches condition", func() {
958-
erbTemplateContent = `<% if p('providers').any? { |p| p['type'] == 'hsm' } %>
957+
erbTemplateContent = `<% if p('providers').any? { |p| p['type'] == 'hsm' } -%>
959958
using_hsm: true
960959
<% end -%>
961-
<% if !p('empty_list').any? %>
960+
<% if !p('empty_list').any? -%>
962961
list_empty: true
963962
<% end -%>`
964-
expectedTemplateContents = `
965-
using_hsm: true
963+
expectedTemplateContents = `using_hsm: true
966964
list_empty: true
967965
`
968966

@@ -1001,20 +999,19 @@ list_empty: true
1001999
})
10021000

10031001
It("checks for empty strings and arrays", func() {
1004-
erbTemplateContent = `<% if p('optional_cert').empty? %>
1002+
erbTemplateContent = `<% if p('optional_cert').empty? -%>
10051003
no_cert: true
10061004
<% end -%>
1007-
<% if !p('required_key').empty? %>
1005+
<% if !p('required_key').empty? -%>
10081006
has_key: true
10091007
<% end -%>
1010-
<% if p('empty_array').empty? %>
1008+
<% if p('empty_array').empty? -%>
10111009
array_empty: true
10121010
<% end -%>
1013-
<% if !p('filled_array').empty? %>
1011+
<% if !p('filled_array').empty? -%>
10141012
array_filled: true
10151013
<% end -%>`
1016-
expectedTemplateContents = `
1017-
no_cert: true
1014+
expectedTemplateContents = `no_cert: true
10181015
has_key: true
10191016
array_empty: true
10201017
array_filled: true
@@ -1053,14 +1050,13 @@ array_filled: true
10531050
})
10541051

10551052
It("checks array membership", func() {
1056-
erbTemplateContent = `<% if p('valid_modes').include?(p('selected_mode')) %>
1053+
erbTemplateContent = `<% if p('valid_modes').include?(p('selected_mode')) -%>
10571054
valid_selection: true
10581055
<% end -%>
1059-
<% if p('tls_modes').include?('enabled') %>
1056+
<% if p('tls_modes').include?('enabled') -%>
10601057
supports_tls: true
10611058
<% end -%>`
1062-
expectedTemplateContents = `
1063-
valid_selection: true
1059+
expectedTemplateContents = `valid_selection: true
10641060
supports_tls: true
10651061
`
10661062

0 commit comments

Comments
 (0)