Integrate the dustjs official helpers into the test framework.

This commit is contained in:
Tom Alexander 2020-05-10 13:43:32 -04:00
parent f9212d1fe4
commit 012028b0bc
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 24 additions and 7 deletions

View File

@ -10,7 +10,7 @@ RUN addgroup -S duster && adduser -S duster -G duster
# Install LinkedIn DustJS. Installing it globally before copying in # Install LinkedIn DustJS. Installing it globally before copying in
# the repo to avoid spamming the npm servers with every codebase # the repo to avoid spamming the npm servers with every codebase
# change. # change.
RUN npm install -g dustjs-linkedin RUN npm install -g dustjs-linkedin dustjs-helpers
# Copy repo into duster user's directory # Copy repo into duster user's directory
@ -22,5 +22,5 @@ RUN chown -R duster:duster /home/duster/duster
USER duster USER duster
RUN git clean -dfxq RUN git clean -dfxq
RUN cargo build RUN cargo build
RUN npm link dustjs-linkedin RUN npm link dustjs-linkedin dustjs-helpers
ENTRYPOINT ["/home/duster/duster/js/run_compliance_suite.bash"] ENTRYPOINT ["/home/duster/duster/js/run_compliance_suite.bash"]

View File

@ -1,20 +1,21 @@
var dust = require('dustjs-linkedin'); // var dust = require("dustjs-linkedin");
var fs = require('fs'); var dust = require("dustjs-helpers");
const path = require('path'); var fs = require("fs");
const path = require("path");
var argv = process.argv.slice(2); var argv = process.argv.slice(2);
if (argv.length < 1) { if (argv.length < 1) {
console.error("Expecting only 1 argument (a path to a template)"); console.error("Expecting only 1 argument (a path to a template)");
process.exit(1); process.exit(1);
} }
var context = JSON.parse(fs.readFileSync(0, 'utf-8')); var context = JSON.parse(fs.readFileSync(0, "utf-8"));
var main_template = path.parse(argv[0])["name"]; var main_template = path.parse(argv[0])["name"];
for (var i = 0, len = argv.length; i < len; ++i) { for (var i = 0, len = argv.length; i < len; ++i) {
var filename = path.parse(argv[i])["name"]; var filename = path.parse(argv[i])["name"];
try { try {
var template_source = fs.readFileSync(argv[i], 'utf-8'); var template_source = fs.readFileSync(argv[i], "utf-8");
} catch (err) { } catch (err) {
console.error(err); console.error(err);
process.exit(1); process.exit(1);

View File

@ -0,0 +1,6 @@
{
"str": "master",
"int": 7,
"alpha": 21,
"beta": "21"
}

View File

@ -0,0 +1,10 @@
Testing helpers:{~n}
str is {str}{~n}
int is {int}{~n}
alpha is {alpha}{~n}
beta is {beta}{~n}
{@eq key=str value="master"}str is equal to "master"{:else}str does not equal "master"{/eq}{~n}
{@eq key=str value="7"}str is equal to "7"{:else}str does not equal "7"{/eq}{~n}
{@eq key=int value="7"}int is equal to "7"{:else}int does not equal "7"{/eq}{~n}
{@eq key=int value=7}int is equal to 7{:else}int does not equal 7{/eq}{~n}
{@eq key=alpha value=beta}alpha is equal to beta{:else}alpha does not equal beta{/eq}{~n}