Add job name and id in log
This commit is contained in:
1 parent
b263e2746c
commit
05e448c4c5
1 file changed
+5
-5
@@ -124,7 +124,7 @@ class NetworkService {
|
|||||||
*/
|
*/
|
||||||
async requestHttp(job) {
|
async requestHttp(job) {
|
||||||
try {
|
try {
|
||||||
const { url, secret, _id, teamId, type, jsonPath, matchMethod, expectedValue } = job.data;
|
const { url, secret, _id, name, teamId, type, jsonPath, matchMethod, expectedValue } = job.data;
|
||||||
const config = {};
|
const config = {};
|
||||||
|
|
||||||
secret !== undefined && (config.headers = { Authorization: `Bearer ${secret}` });
|
secret !== undefined && (config.headers = { Authorization: `Bearer ${secret}` });
|
||||||
@@ -158,13 +158,13 @@ class NetworkService {
|
|||||||
this.logger.info({
|
this.logger.info({
|
||||||
service: this.SERVICE_NAME,
|
service: this.SERVICE_NAME,
|
||||||
method: "requestHttp",
|
method: "requestHttp",
|
||||||
message: "match result with expected value",
|
message: `Job: [${name}](${_id}) match result with expected value`,
|
||||||
details: { expectedValue, result, jsonPath, matchMethod }
|
details: { expectedValue, result, jsonPath, matchMethod }
|
||||||
});
|
});
|
||||||
|
|
||||||
if (jsonPath) {
|
if (jsonPath) {
|
||||||
const contentType = response.headers['content-type'];
|
const contentType = response.headers['content-type'];
|
||||||
|
|
||||||
if (contentType && contentType.includes('application/json')) {
|
if (contentType && contentType.includes('application/json')) {
|
||||||
try {
|
try {
|
||||||
result = jmespath.search(result, jsonPath);
|
result = jmespath.search(result, jsonPath);
|
||||||
@@ -191,7 +191,7 @@ class NetworkService {
|
|||||||
if (matchMethod === "include") match = result.includes(expectedValue);
|
if (matchMethod === "include") match = result.includes(expectedValue);
|
||||||
else if (matchMethod === "regex") match = new RegExp(expectedValue).test(result);
|
else if (matchMethod === "regex") match = new RegExp(expectedValue).test(result);
|
||||||
else match = result === expectedValue;
|
else match = result === expectedValue;
|
||||||
|
|
||||||
httpResponse.status = match;
|
httpResponse.status = match;
|
||||||
httpResponse.message = match ? "Match" : "Not Match";
|
httpResponse.message = match ? "Match" : "Not Match";
|
||||||
return httpResponse;
|
return httpResponse;
|
||||||
|
|||||||
Reference in new issue
Block a user