Add tests for web instance

This commit is contained in:
linguist
2020-12-30 18:14:20 +01:00
parent a8fe11b7b5
commit 6290ca575c
9 changed files with 294 additions and 226 deletions

View File

@@ -12,7 +12,7 @@
import util from "util"
//Setup
export default async function metrics({login, q, dflags = []}, {graphql, rest, plugins, conf, die = false}, {Plugins, Templates}) {
export default async function metrics({login, q, dflags = []}, {graphql, rest, plugins, conf, die = false, verify = false}, {Plugins, Templates}) {
//Compute rendering
try {
@@ -92,6 +92,15 @@
rendered = optimized
}
//Verify svg
if (verify) {
console.debug(`metrics/compute/${login} > verify SVG`)
const libxmljs = (await import("libxmljs")).default
const parsed = libxmljs.parseXml(rendered)
if (parsed.errors.length)
throw new Error(`Malformed SVG : \n${parsed.errors.join("\n")}`)
}
//Result
console.debug(`metrics/compute/${login} > success`)
return rendered