The problem
"body" : "[{{#each (range 0 20) as |index|}} [ {{math (now format='epoch') '+' (math index '*' 86400000)}}, {{randomDecimal lower=190.0 upper=220.0}} ] {{#if @last}}{{else}},{{/if}}{{/each}}]",
This will generate a body that looks like
[ [ 0, 196.3580633809619 ] , [ 86400000, 196.39208777016043 ] , [ 172800000, 197.86647674155523 ] , [ 259200000, 205.36354784502032 ] , [ 345600000, 192.65030129839516 ] ..... ]
As you can see it seems like math treats the output from (now format='epoch') as zero. If I use now format='epoch' outside the context of math, it works like a charm.
Might it be that now format='epoch' returns a string or something else that makes math lay down and die?
Details
- Version: 2.33.2
- Starting the server
docker run -d --name wiremock-timeseries --network host -v $PWD/timeseries-wiremock:/home/wiremock -e uid=$(id -u) wiremock/wiremock --port="8083" --local-response-templating --verbose
- The full stub (I removed a bunch of stuff I do not want to leave the company)
{
"id" : "04056434-098e-3775-a070-1ca35778aa25",
"request" : {
"urlPattern": "/.*",
"method" : "POST"
},
"response" : {
"transformers": ["response-template"],
"status" : 200,
"body" : "[{{#each (range 0 20) as |index|}} [ {{math (now format='epoch') '+' (math index '*' 86400000)}}, {{randomDecimal lower=190.0 upper=220.0}} ] {{#if @last}}{{else}},{{/if}}{{/each}}]",
"headers" : {
"Date" : "Mon, 05 Sep 2022 14:17:55 GMT",
"Content-Type" : "application/json",
"X-Content-Type-Options" : "nosniff",
"X-XSS-Protection" : "1; mode=block",
"Cache-Control" : "no-cache, no-store, max-age=0, must-revalidate",
"Pragma" : "no-cache",
"Expires" : "0"
}
},
"uuid" : "04056434-098e-3775-a070-1ca35778aa25"
}
The problem
This will generate a body that looks like
As you can see it seems like
mathtreats the output from(now format='epoch')as zero. If I usenow format='epoch'outside the context ofmath, it works like a charm.Might it be that
now format='epoch'returns a string or something else that makesmathlay down and die?Details
docker run -d --name wiremock-timeseries --network host -v $PWD/timeseries-wiremock:/home/wiremock -e uid=$(id -u) wiremock/wiremock --port="8083" --local-response-templating --verbose