Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai committed Feb 29, 2024
1 parent 6af2f72 commit 9e8af1c
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 0 deletions.
93 changes: 93 additions & 0 deletions test/integrations/destinations/marketo/dataDelivery/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,97 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
},
},
},
{
id: 'marketo_v1_scenario_6',
name: 'marketo',
description: '[Proxy v1 API] :: Test for missing content type header scenario',
successCriteria: 'Should return a 612 status code with Invalid Content Type ',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
headers: {
Authorization: 'Bearer test_token_6',
'Content-Type': 'invalid',
'User-Agent': 'RudderLabs',
},
endpoint: 'https://mktId.mktorest.com/rest/v1/leads.json/test_invalid_header',
},
reqMetadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 400,
statTags: statTags.aborted,
message:
'Request Failed for marketo, Invalid Content Type (Aborted).during Marketo Response Handling',
response: [
{
error:
'{"success":false,"errors":[{"code":"612","message":"Invalid Content Type"}]}',
metadata: proxyMetdata,
statusCode: 400,
},
],
},
},
},
},
},
{
id: 'marketo_v1_scenario_7',
name: 'marketo',
description: '[Proxy v1 API] :: Test for a passed field exceeding max length',
successCriteria: 'Should return a 1077 status code with Value for field exceeds max length',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
headers: {
Authorization: 'Bearer test_token_6',
'Content-Type': 'application/json',
'User-Agent': 'RudderLabs',
},
endpoint: 'https://mktId.mktorest.com/rest/v1/leads.json/test_exceeded_length',
},
reqMetadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 400,
statTags: statTags.aborted,
message: 'Request failed with status: 400',
response: [
{
error:
'{"success":false,"errors":[{"code":"1077","message":"Value for field exceeds max length"}]}',
metadata: proxyMetdata,
statusCode: 400,
},
],
},
},
},
},
},
];
50 changes: 50 additions & 0 deletions test/integrations/destinations/marketo/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,56 @@ const businessMockData = [
statusText: 'OK',
},
},
{
description: 'Mock response for a failed lead request due to invalid header',
httpReq: {
url: 'https://mktId.mktorest.com/rest/v1/leads.json/test_invalid_header',
headers: {
Authorization: 'Bearer test_token_6',
'Content-Type': 'invalid',
'User-Agent': 'RudderLabs',
},
method: 'POST',
},
httpRes: {
data: {
success: false,
errors: [
{
code: '612',
message: 'Invalid Content Type',
},
],
},
status: 200,
statusText: 'OK',
},
},
{
description: 'Mock response for a failed lead request due to length exceeded',
httpReq: {
url: 'https://mktId.mktorest.com/rest/v1/leads.json/test_exceeded_length',
headers: {
Authorization: 'Bearer test_token_6',
'Content-Type': 'application/json',
'User-Agent': 'RudderLabs',
},
method: 'POST',
},
httpRes: {
data: {
success: false,
errors: [
{
code: '1077',
message: 'Value for field exceeds max length',
},
],
},
status: 400,
statusText: 'OK',
},
},
];

export const networkCallsData = [...businessMockData, ...tfProxyMocksData];

0 comments on commit 9e8af1c

Please sign in to comment.