diff options
author | Håkon Hallingstad <hakon@yahooinc.com> | 2022-01-10 00:00:43 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@yahooinc.com> | 2022-01-10 00:00:43 +0100 |
commit | 96ff49a50ce0569e9b7664c9ed3fb87d7e72cf17 (patch) | |
tree | 73f9362af94c7652160094c0e4218bf8187d05df /node-admin/src/test | |
parent | 8f58bcc8f3e6e6831bb609ffb72f32785184d2a2 (diff) |
Support comment and per-directive newline removal
Diffstat (limited to 'node-admin/src/test')
4 files changed, 41 insertions, 10 deletions
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFileTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFileTest.java index dd1a1abb6bc..be73caf9d1d 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFileTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFileTest.java @@ -67,7 +67,38 @@ class TemplateFileTest { form.render()); } + @Test + void verifyNewlineRemoval() { + Form form = makeForm("a%{list a}\n" + + "b%{end}\n" + + "c%{list c|}\n" + + "d%{end|}\n" + + "e\n"); + form.add("a"); + form.add("c"); + + assertEquals("a\n" + + "b\n" + + "cde\n", + form.render()); + } + + @Test + void verifyComment() { + assertEquals("first\n" + + "second\n" + + "third and still third\n", + makeForm("first\n" + + "second%{#} rest of line is ignored\n" + + "third%{#|} this line continues on the next\n" + + " and still third\n").render()); + } + private Form getForm(String filename) { return TemplateFile.read(Path.of("src/test/resources/" + filename)).instantiate(); } + + private Form makeForm(String templateText) { + return Template.from(templateText).instantiate(); + } }
\ No newline at end of file diff --git a/node-admin/src/test/resources/template1.tmp b/node-admin/src/test/resources/template1.tmp index a020dbb0739..62b629520bf 100644 --- a/node-admin/src/test/resources/template1.tmp +++ b/node-admin/src/test/resources/template1.tmp @@ -1,10 +1,10 @@ variable section '%{=varname}' -%{list listname} +%{list listname|} same variable section '%{=varname}' different variable section '%{=varname2}' -%{list innerlistname} +%{list innerlistname|} inner list text -%{end} +%{end|} between ends -%{end} +%{end|} end of text diff --git a/node-admin/src/test/resources/template2.tmp b/node-admin/src/test/resources/template2.tmp index d36cb4a4a48..4a6be865d18 100644 --- a/node-admin/src/test/resources/template2.tmp +++ b/node-admin/src/test/resources/template2.tmp @@ -1,4 +1,4 @@ -%{list listA}body A -%{list listB}body B -%{end} -%{end} +%{list listA|}body A +%{list listB|}body B +%{end|} +%{end|} diff --git a/node-admin/src/test/resources/template3.tmp b/node-admin/src/test/resources/template3.tmp index 27566e72a9d..372dfa62193 100644 --- a/node-admin/src/test/resources/template3.tmp +++ b/node-admin/src/test/resources/template3.tmp @@ -1,6 +1,6 @@ %{=varname} %{=varname} -%{list l} +%{list l|} inner %{=varname} %{=innerVarSetAtTop} -%{end} +%{end|} |