Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandra shekar Varkala committed Jan 22, 2024
1 parent a8cad9b commit 04074af
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
26 changes: 9 additions & 17 deletions src/v0/destinations/__rudder_test__/transform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-restricted-syntax */
const groupBy = require('lodash/groupBy');
const cloneDeep = require('lodash/cloneDeep');
const lodash = require('lodash');
const {
removeUndefinedAndNullValues,
getSuccessRespEvents,
Expand Down Expand Up @@ -49,21 +49,13 @@ const process = (event) => {
};
return removeUndefinedAndNullValues(outputEvent);
};

/**
* This functions takes event matadata and updates it based on the transformed and raw paylaod
* the outputEvent is the transformed event which is guranateed to contain the topic
* @param {*} input
* @returns {*} metadata
*/
const processMetadata = (input) => {
const { metadata, outputEvent } = input;
const clonedMetadata = cloneDeep(metadata);
const { topic } = outputEvent;
if (topic) {
clonedMetadata.rudderId = `${clonedMetadata.rudderId}<<>>${topic}`;
}
return clonedMetadata;
const processRouterDest = async (inputs, reqMetadata) => {

Check failure on line 52 in src/v0/destinations/__rudder_test__/transform.js

View workflow job for this annotation

GitHub Actions / Code Coverage

'reqMetadata' is defined but never used
// group events by userId or anonymousId and then call process
const groupedInputs = lodash.groupBy(
inputs,
(input) => input.message.userId || input.message.anonymousId,
);
return batch(groupedInputs);
};

module.exports = { process, batch, processMetadata };
module.exports = { process, batch, processRouterDest };
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@
}
}
],
"destType": "am"
"destType": "__rudder_test__"
},
"output": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@
}
}
],
"destType": "am"
"destType": "__rudder_test__"
},
"output": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@
}
}
],
"destType": "pinterest_tag"
"destType": "__rudder_test__"
},
"output": {
"output": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@
}
}
],
"destType": "webhook"
"destType": "__rudder_test__"
},
"output": {
"output": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@
}
}
],
"destType": "webhook"
"destType": "__rudder_test__"
},
"output": {
"output": [
Expand Down
31 changes: 21 additions & 10 deletions test/apitests/service.api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Koa from 'koa';
import bodyParser from 'koa-bodyparser';
import { applicationRoutes } from '../../src/routes';
import exp from 'constants';
const testT = require('../../src/v0/destinations/__rudder_test__/transform');


let server: any;
const OLD_ENV = process.env;
Expand Down Expand Up @@ -38,40 +40,49 @@ const getDataFromPath = (pathInput) => {
describe('Destination api tests', () => {
describe('Processor transform tests', () => {
test('(webhook) success scenario with single event', async () => {
/* const data = getDataFromPath('./data_scenarios/destination/proc/sucess.json');
const process = jest.spyOn(testT, 'process').mockImplementation((event, m) => {
console.log("testDest - process - mockImplementation");
});

const data = getDataFromPath('./data_scenarios/destination/proc/sucess.json');
const response = await request(server)
.post('/v0/destinations/webhook')
.post('/v0/destinations/__rudder_test__')
.set('Accept', 'application/json')
.send(data.input);
expect(response.status).toEqual(200);
expect(JSON.parse(response.text)).toEqual(data.output); */
expect(true).toEqual(true);
//console.log(JSON.parse(response.text));
});
});

describe('Batch transform tests', () => {
test('(am) successful batch transform', async () => {
/* const data = getDataFromPath('./data_scenarios/destination/batch/successful_batch.json');
const batch = jest.spyOn(testT, 'batch').mockImplementation((event, m) => {
console.log("testDest - batch - mockImplementation");
});

const data = getDataFromPath('./data_scenarios/destination/batch/successful_batch.json');
const response = await request(server)
.post('/batch')
.set('Accept', 'application/json')
.send(data.input);
expect(response.status).toEqual(200);
expect(JSON.parse(response.text)).toEqual(data.output); */
expect(true).toEqual(true);
//expect(JSON.parse(response.text)).toEqual(data.output);
});
});

describe('Router transform tests', () => {
test('(webhook) successful router transform', async () => {
/* const data = getDataFromPath('./data_scenarios/destination/router/successful_test.json');
const processRouterDest = jest.spyOn(testT, 'processRouterDest').mockImplementation((event, m) => {
console.log("testDest - processRouterDest - mockImplementation");
});

const data = getDataFromPath('./data_scenarios/destination/router/successful_test.json');
const response = await request(server)
.post('/routerTransform')
.set('Accept', 'application/json')
.send(data.input);
expect(response.status).toEqual(200);
expect(JSON.parse(response.text)).toEqual(data.output); */
expect(true).toEqual(true);
//expect(JSON.parse(response.text)).toEqual(data.output);
});
});
});

0 comments on commit 04074af

Please sign in to comment.