Skip to content

Commit

Permalink
chore: add assertions for router transform and batch outputs (#2982)
Browse files Browse the repository at this point in the history
  • Loading branch information
chandumlg authored Jan 23, 2024
1 parent 724a4ac commit de4e321
Show file tree
Hide file tree
Showing 144 changed files with 20,049 additions and 31,486 deletions.
30 changes: 20 additions & 10 deletions test/__tests__/data/pinterest_tag_router_batch_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@
},
"metadata": [
{
"jobId": 1
"jobId": 1,
"userId": "u1"
},
{
"jobId": 2
"jobId": 2,
"userId": "u1"
}
],
"batched": true,
Expand Down Expand Up @@ -329,13 +331,16 @@
},
"metadata": [
{
"jobId": 3
"jobId": 3,
"userId": "u1"
},
{
"jobId": 4
"jobId": 4,
"userId": "u1"
},
{
"jobId": 6
"jobId": 6,
"userId": "u1"
}
],
"batched": true,
Expand Down Expand Up @@ -445,7 +450,8 @@
},
"metadata": [
{
"jobId": 7
"jobId": 7,
"userId": "u1"
}
],
"batched": true,
Expand Down Expand Up @@ -496,7 +502,8 @@
{
"metadata": [
{
"jobId": 5
"jobId": 5,
"userId": "u1"
}
],
"batched": false,
Expand Down Expand Up @@ -736,10 +743,12 @@
},
"metadata": [
{
"jobId": 8
"jobId": 8,
"userId": "u1"
},
{
"jobId": 9
"jobId": 9,
"userId": "u1"
}
],
"statusCode": 200
Expand Down Expand Up @@ -852,7 +861,8 @@
},
"metadata": [
{
"jobId": 10
"jobId": 10,
"userId": "u1"
}
],
"statusCode": 200
Expand Down
3 changes: 2 additions & 1 deletion test/__tests__/data/pinterest_tag_router_error_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
}
},
"metadata": {
"jobId": 5
"jobId": 5,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down
3 changes: 2 additions & 1 deletion test/__tests__/data/pinterest_tag_router_error_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
{
"metadata": [
{
"jobId": 5
"jobId": 5,
"userId": "u1"
}
],
"batched": false,
Expand Down
30 changes: 20 additions & 10 deletions test/__tests__/data/pinterest_tag_router_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
}
},
"metadata": {
"jobId": 1
"jobId": 1,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down Expand Up @@ -198,7 +199,8 @@
}
},
"metadata": {
"jobId": 2
"jobId": 2,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down Expand Up @@ -300,7 +302,8 @@
}
},
"metadata": {
"jobId": 3
"jobId": 3,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down Expand Up @@ -421,7 +424,8 @@
}
},
"metadata": {
"jobId": 4
"jobId": 4,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down Expand Up @@ -542,7 +546,8 @@
}
},
"metadata": {
"jobId": 5
"jobId": 5,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down Expand Up @@ -663,7 +668,8 @@
}
},
"metadata": {
"jobId": 6
"jobId": 6,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down Expand Up @@ -764,7 +770,8 @@
"files": {}
},
"metadata": {
"jobId": 7
"jobId": 7,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down Expand Up @@ -888,7 +895,8 @@
}
},
"metadata": {
"jobId": 8
"jobId": 8,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down Expand Up @@ -1011,7 +1019,8 @@
}
},
"metadata": {
"jobId": 9
"jobId": 9,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down Expand Up @@ -1134,7 +1143,8 @@
}
},
"metadata": {
"jobId": 10
"jobId": 10,
"userId": "u1"
},
"destination": {
"ID": "1pYpzzvcn7AQ2W9GGIAZSsN6Mfq",
Expand Down
30 changes: 20 additions & 10 deletions test/__tests__/data/pinterest_tag_router_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,22 +294,28 @@
},
"metadata": [
{
"jobId": 1
"jobId": 1,
"userId": "u1"
},
{
"jobId": 2
"jobId": 2,
"userId": "u1"
},
{
"jobId": 3
"jobId": 3,
"userId": "u1"
},
{
"jobId": 4
"jobId": 4,
"userId": "u1"
},
{
"jobId": 6
"jobId": 6,
"userId": "u1"
},
{
"jobId": 7
"jobId": 7,
"userId": "u1"
}
],
"batched": true,
Expand Down Expand Up @@ -360,7 +366,8 @@
{
"metadata": [
{
"jobId": 5
"jobId": 5,
"userId": "u1"
}
],
"statTags": {
Expand Down Expand Up @@ -593,13 +600,16 @@
},
"metadata": [
{
"jobId": 8
"jobId": 8,
"userId": "u1"
},
{
"jobId": 9
"jobId": 9,
"userId": "u1"
},
{
"jobId": 10
"jobId": 10,
"userId": "u1"
}
],
"batched": true,
Expand Down
3 changes: 3 additions & 0 deletions test/__tests__/pinterestConversion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const path = require("path");
const version = "v0";

const transformer = require(`../../src/${version}/destinations/${integration}/transform`);
const { assertRouterOutput } = require('../testHelper');

const inputDataFile = fs.readFileSync(
path.resolve(__dirname, `./data/${integration}_input.json`)
);
Expand Down Expand Up @@ -44,6 +46,7 @@ describe(`${name} Tests`, () => {
inputRouterData.forEach((input, index) => {
it(`Payload: ${index}`, async () => {
let output = await transformer.processRouterDest(input);
assertRouterOutput(output, input);
expect(output).toEqual(expectedRouterData[index]);
});
});
Expand Down
6 changes: 5 additions & 1 deletion test/__tests__/utilities/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require("fs");
const _ = require("lodash");
const path = require("path");
const { ConfigFactory, Executor } = require("rudder-transformer-cdk");
const { assertRouterOutput } = require('../../testHelper');

// TODO: separate this out later as the list grows
const cdkEnabledDestinations = {
Expand Down Expand Up @@ -95,7 +96,9 @@ function executeTransformationTest(dest, transformAt) {
if (transformAt == "processor") {
actualData = await transformer.process(tcInput);
} else {
actualData = (await transformer.processRouterDest([tcInput]))[0];
actual = await transformer.processRouterDest([tcInput])
assertRouterOutput(actual, [tcInput]);
actualData = (actual)[0];
}
}
// Compare actual and expected data
Expand All @@ -115,6 +118,7 @@ function executeTransformationTest(dest, transformAt) {
const version = "v0";
const transformer = require(`../../../src/${version}/destinations/${dest}/transform`);
actualData = await transformer.processRouterDest(commonInput);
assertRouterOutput(actualData, commonInput);
const cloneActual = _.cloneDeep(actualData);
cloneActual[0].statTags = "undefined";
// Compare actual and expected data
Expand Down
Loading

0 comments on commit de4e321

Please sign in to comment.