Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add assertions for router transform and batch outputs #2982

Merged
merged 6 commits into from
Jan 23, 2024
Merged
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
30 changes: 20 additions & 10 deletions test/__tests__/data/pinterest_tag_router_batch_output.json
chandumlg marked this conversation as resolved.
Show resolved Hide resolved
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
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
Loading