Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ var API = module.exports = function (opts) {
req_id: req.id
};

// TODO should be handled by backend itself
// TODO direct call deleteWorkflow(uuid)
// TODO not necessary to fetch whole workflow
backend.getWorkflow(req.params.uuid, function (err, workflow) {
if (err) {
return next(err.toRestError);
Expand Down
58 changes: 43 additions & 15 deletions test/child.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,24 @@ var task = {
};


test('unkown message', function (t) {
test('unknown message', function (t) {
var child = fork(__dirname + '/../lib/child.js');

child.on('message', function (msg) {
t.ifError(msg.job);
t.ok(msg.error);
t.ok(msg.error, 'should have error');
t.equal(msg.error, 'unknown message');
if (child.exitCode === null) {
child.kill();
}
});

child.on('exit', function (code, signal) {
t.ok(code);
if (signal == "SIGTERM") {
t.notOk(code, "child.on('exit'): should not have code, if killed by parent");
} else {
t.ok(code, "child.on('exit'): should have code, if exited normally");
}
t.end();
});

Expand All @@ -64,8 +68,12 @@ test('message without job', function (t) {
}
});

child.on('exit', function (code) {
t.ok(code);
child.on('exit', function (code, signal) {
if (signal == "SIGTERM") {
t.notOk(code, "child.on('exit'): should not have code, if killed by parent");
} else {
t.ok(code, "child.on('exit'): should have code, if exited normally");
}
t.end();
});

Expand All @@ -86,8 +94,12 @@ test('message without task', function (t) {
}
});

child.on('exit', function (code) {
t.ok(code);
child.on('exit', function (code, signal) {
if (signal == "SIGTERM") {
t.notOk(code, "child.on('exit'): should not have code, if killed by parent");
} else {
t.ok(code, "child.on('exit'): should have code, if exited normally");
}
t.end();
});

Expand All @@ -108,8 +120,12 @@ test('message with invalid task', function (t) {
}
});

child.on('exit', function (code) {
t.ok(code);
child.on('exit', function (code, signal) {
if (signal == "SIGTERM") {
t.notOk(code, "child.on('exit'): should not have code, if killed by parent");
} else {
t.ok(code, "child.on('exit'): should have code, if exited normally");
}
t.end();
});

Expand Down Expand Up @@ -138,8 +154,12 @@ test('message with successful task', function (t) {
}
});

child.on('exit', function (code) {
t.ok(code);
child.on('exit', function (code, signal) {
if (signal == "SIGTERM") {
t.notOk(code, "child.on('exit'): should not have code, if killed by parent");
} else {
t.ok(code, "child.on('exit'): should have code, if exited normally");
}
t.end();
});

Expand Down Expand Up @@ -168,8 +188,12 @@ test('message with failed task', function (t) {
}
});

child.on('exit', function (code) {
t.ok(code);
child.on('exit', function (code, signal) {
if (signal == "SIGTERM") {
t.notOk(code, "child.on('exit'): should not have code, if killed by parent");
} else {
t.ok(code, "child.on('exit'): should have code, if exited normally");
}
t.end();
});

Expand Down Expand Up @@ -206,8 +230,12 @@ test('cancel message', function (t) {
}
});

child.on('exit', function (code) {
t.ok(code);
child.on('exit', function (code, signal) {
if (signal == "SIGTERM") {
t.notOk(code, "child.on('exit'): should not have code, if killed by parent");
} else {
t.ok(code, "child.on('exit'): should have code, if exited normally");
}
t.end();
});

Expand Down