1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix flow api unit tests

This commit is contained in:
Nick O'Leary 2020-09-29 17:35:43 +01:00
parent ea45dde63a
commit 7a90fe5aec
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 7 additions and 4 deletions

View File

@ -194,14 +194,13 @@ var api = module.exports = {
var id = opts.id; var id = opts.id;
return runtime.flows.removeFlow(id, opts.user).then(function () { return runtime.flows.removeFlow(id, opts.user).then(function () {
runtime.log.audit({event: "flow.remove", id: id}, opts.req); runtime.log.audit({event: "flow.remove", id: id}, opts.req);
return resolve(); return;
}).catch(function (err) { }).catch(function (err) {
if (err.code === 404) { if (err.code === 404) {
runtime.log.audit({event: "flow.remove", id: id, error: "not_found"}, opts.req); runtime.log.audit({event: "flow.remove", id: id, error: "not_found"}, opts.req);
// TODO: this swap around of .code and .status isn't ideal // TODO: this swap around of .code and .status isn't ideal
err.status = 404; err.status = 404;
err.code = "not_found"; err.code = "not_found";
return reject(err);
} else { } else {
runtime.log.audit({ runtime.log.audit({
event: "flow.remove", event: "flow.remove",

View File

@ -255,7 +255,9 @@ describe("runtime-api/flows", function() {
var err = new Error(); var err = new Error();
// TODO: quirk of internal api - uses .code for .status // TODO: quirk of internal api - uses .code for .status
err.code = 404; err.code = 404;
throw err; var p = Promise.reject(err);
p.catch(()=>{});
return p;
} else if (id === "error") { } else if (id === "error") {
var err = new Error(); var err = new Error();
// TODO: quirk of internal api - uses .code for .status // TODO: quirk of internal api - uses .code for .status
@ -311,7 +313,9 @@ describe("runtime-api/flows", function() {
var err = new Error(); var err = new Error();
// TODO: quirk of internal api - uses .code for .status // TODO: quirk of internal api - uses .code for .status
err.code = 404; err.code = 404;
throw err; var p = Promise.reject(err);
p.catch(()=>{});
return p;
} else if (flow === "error") { } else if (flow === "error") {
var err = new Error(); var err = new Error();
// TODO: quirk of internal api - uses .code for .status // TODO: quirk of internal api - uses .code for .status