forked from cfengine/core
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Acceptance test for rendering quotes in mustache
- Loading branch information
1 parent
258fa1d
commit 51ca2ac
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
tests/acceptance/10_files/templating/mustache_render_quote.cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
####################################################### | ||
# | ||
# Acceptance test to ensure that mustache renders quotes in variables | ||
# correctly. | ||
# | ||
# Redmine: https://dev.cfengine.com/issues/6516 | ||
####################################################### | ||
|
||
body common control | ||
{ | ||
inputs => { "../../default.cf.sub" }; | ||
bundlesequence => { default("$(this.promise_filename)") }; | ||
version => "1.0"; | ||
|
||
} | ||
|
||
####################################################### | ||
|
||
bundle agent init | ||
{ | ||
vars: | ||
"variable_containing_double_quote" string => 'Something "special" with quotes'; | ||
"variable_containing_single_quote" string => "Something 'special' with quotes"; | ||
|
||
files: | ||
"$(G.testfile)" | ||
delete => init_delete; | ||
} | ||
|
||
body delete init_delete | ||
{ | ||
dirlinks => "delete"; | ||
rmdirs => "true"; | ||
} | ||
|
||
####################################################### | ||
|
||
bundle agent test | ||
{ | ||
vars: | ||
"template_file" string => "$(this.promise_filename).mustache"; | ||
|
||
files: | ||
"$(G.testfile)" | ||
create => "true", | ||
edit_template => "$(template_file)", | ||
template_method => "mustache"; | ||
|
||
reports: | ||
DEBUG:: | ||
"Rendering template file $(template_file) to $(G.testfile)"; | ||
} | ||
|
||
####################################################### | ||
|
||
bundle agent check | ||
{ | ||
vars: | ||
"expect" string => readfile("$(this.promise_filename).expected", 4000); | ||
"actual" string => readfile("$(G.testfile)", 4000); | ||
|
||
classes: | ||
"ok" expression => regcmp("$(expect)", "$(actual)"); | ||
|
||
reports: | ||
DEBUG:: | ||
"expect: '$(expect)'"; | ||
"actual: '$(actual)'"; | ||
ok:: | ||
"$(this.promise_filename) Pass"; | ||
!ok:: | ||
"$(this.promise_filename) FAIL"; | ||
} | ||
### PROJECT_ID: core | ||
### CATEGORY_ID: 27 |
2 changes: 2 additions & 0 deletions
2
tests/acceptance/10_files/templating/mustache_render_quote.cf.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Something "special" with quotes | ||
Something 'special' with quotes |
2 changes: 2 additions & 0 deletions
2
tests/acceptance/10_files/templating/mustache_render_quote.cf.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{vars.init.variable_containing_double_quote}} | ||
{{vars.init.variable_containing_single_quote}} |