Skip to content

Commit

Permalink
refactor code and add negative test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip committed Oct 27, 2023
1 parent 06100dd commit 905b764
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/cdk/v2/destinations/tiktok_audience/rtWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ steps:
loopOverInput: true

- name: successfulEvents
debug: true
template: |
$.outputs.transform.map(function(transformedData,index){
const result = {
"batchedRequest": transformedData.output,
$.outputs.transform#idx{"output" in .}.({
"batchedRequest": .output,
"batched": true,
"destination": ^[index].destination,
"metadata": ^[index].metadata[],
"destination": ^[idx].destination,
"metadata": ^[idx].metadata[],
"statusCode": 200
}
result;
})
})[]
- name: failedEvents
template: |
$.outputs.transform#idx.error.(
Expand Down
95 changes: 95 additions & 0 deletions test/integrations/destinations/tiktok_audience/router/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,65 @@ export const data = [
},
},
},
{
message: {
userId: 'user 1',
properties: {
listData: {
add: [
{
EMAIL_SHA256: '[email protected]',
PHONE_SHA256: '+129988776655',
AAID_MD5: '000999OOOQQQQ',
IDFA_MD5: '1234lkasfjdalj12321',
},
{
EMAIL_SHA256: '[email protected]',
AAID_SHA256: '000999OOOPPPP',
AAID_MD5: '000999OOOPPPP',
IDFA_MD5: '1234lkasfjdalj114455',
},
],
},
},
context: {
ip: '14.5.67.21',
library: {
name: 'http',
},
externalId: [
{
type: 'TIKTOK_AUDIENCE-23856594064540489',
identifierType: 'EMAIL_SHA256',
},
],
destinationFields:
'EMAIL_SHA256, PHONE_SHA256, IDFA_SHA256, AAID_SHA256, AAID_MD, IDFA_MD5',
},
timestamp: '2020-02-02T00:23:09.544Z',
},
metadata: {
jobId: 1524545,
secret: {
accessToken: 'dummyAccessToken',
advertiserIds: ['dummyAdverTiserID'],
},
},
destination: {
DestinationDefinition: {
Config: {
cdkV2Enabled: true,
},
},
Config: {
isHashRequired: true,
registerDeviceOrBrowserApiKey: true,
apiKey: 'intercomApiKey',
appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0',
collectContext: false,
},
},
},
],
destType: 'tiktok_audience',
},
Expand All @@ -284,6 +343,42 @@ export const data = [
status: 200,
body: {
output: [
{
error: 'message Type is not present. Aborting message.',
batched: false,
destination: {
DestinationDefinition: {
Config: {
cdkV2Enabled: true,
},
},
Config: {
isHashRequired: true,
registerDeviceOrBrowserApiKey: true,
apiKey: 'intercomApiKey',
appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0',
collectContext: false,
},
},
metadata: [
{
jobId: 1524545,
secret: {
accessToken: 'dummyAccessToken',
advertiserIds: ['dummyAdverTiserID'],
},
},
],
statTags: {
destType: 'TIKTOK_AUDIENCE',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
feature: 'router',
implementation: 'cdkV2',
module: 'destination',
},
statusCode: 400,
},
{
batchedRequest: [
{
Expand Down

0 comments on commit 905b764

Please sign in to comment.