Integrate the dustjs official helpers into the test framework.

Tom Alexander 4 years ago
parent f9212d1fe4
commit 012028b0bc
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

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

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

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

@ -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}