-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat.cdkV2-componentTests
- Loading branch information
Showing
17 changed files
with
391 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import ControllerUtility from './index'; | ||
|
||
describe('adaptInputToVersion', () => { | ||
it('should return the input unchanged when the implementation version is not found', () => { | ||
const sourceType = 'NA_SOURCE'; | ||
const requestVersion = 'v0'; | ||
const input = [ | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
]; | ||
const expected = { | ||
implementationVersion: undefined, | ||
input: [ | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
], | ||
}; | ||
|
||
const result = ControllerUtility.adaptInputToVersion(sourceType, requestVersion, input); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
it('should return the input unchanged when the implementation version and request version are the same i.e. v0', () => { | ||
const sourceType = 'pipedream'; | ||
const requestVersion = 'v0'; | ||
const input = [ | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
]; | ||
const expected = { | ||
implementationVersion: 'v0', | ||
input: [ | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
], | ||
}; | ||
|
||
const result = ControllerUtility.adaptInputToVersion(sourceType, requestVersion, input); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
it('should return the input unchanged when the implementation version and request version are the same i.e. v1', () => { | ||
const sourceType = 'webhook'; | ||
const requestVersion = 'v1'; | ||
const input = [ | ||
{ | ||
event: { key1: 'val1', key2: 'val2' }, | ||
source: { id: 'source_id', config: { configField1: 'configVal1' } }, | ||
}, | ||
{ | ||
event: { key1: 'val1', key2: 'val2' }, | ||
source: { id: 'source_id', config: { configField1: 'configVal1' } }, | ||
}, | ||
{ | ||
event: { key1: 'val1', key2: 'val2' }, | ||
source: { id: 'source_id', config: { configField1: 'configVal1' } }, | ||
}, | ||
]; | ||
const expected = { | ||
implementationVersion: 'v1', | ||
input: [ | ||
{ | ||
event: { key1: 'val1', key2: 'val2' }, | ||
source: { id: 'source_id', config: { configField1: 'configVal1' } }, | ||
}, | ||
{ | ||
event: { key1: 'val1', key2: 'val2' }, | ||
source: { id: 'source_id', config: { configField1: 'configVal1' } }, | ||
}, | ||
{ | ||
event: { key1: 'val1', key2: 'val2' }, | ||
source: { id: 'source_id', config: { configField1: 'configVal1' } }, | ||
}, | ||
], | ||
}; | ||
|
||
const result = ControllerUtility.adaptInputToVersion(sourceType, requestVersion, input); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
it('should convert input from v0 to v1 when the request version is v0 and the implementation version is v1', () => { | ||
const sourceType = 'webhook'; | ||
const requestVersion = 'v0'; | ||
const input = [ | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
]; | ||
const expected = { | ||
implementationVersion: 'v1', | ||
input: [ | ||
{ event: { key1: 'val1', key2: 'val2' }, source: undefined }, | ||
{ event: { key1: 'val1', key2: 'val2' }, source: undefined }, | ||
{ event: { key1: 'val1', key2: 'val2' }, source: undefined }, | ||
], | ||
}; | ||
|
||
const result = ControllerUtility.adaptInputToVersion(sourceType, requestVersion, input); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
|
||
it('should convert input from v1 to v0 format when the request version is v1 and the implementation version is v0', () => { | ||
const sourceType = 'pipedream'; | ||
const requestVersion = 'v1'; | ||
const input = [ | ||
{ | ||
event: { key1: 'val1', key2: 'val2' }, | ||
source: { id: 'source_id', config: { configField1: 'configVal1' } }, | ||
}, | ||
{ | ||
event: { key1: 'val1', key2: 'val2' }, | ||
source: { id: 'source_id', config: { configField1: 'configVal1' } }, | ||
}, | ||
{ | ||
event: { key1: 'val1', key2: 'val2' }, | ||
source: { id: 'source_id', config: { configField1: 'configVal1' } }, | ||
}, | ||
]; | ||
const expected = { | ||
implementationVersion: 'v0', | ||
input: [ | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
{ key1: 'val1', key2: 'val2' }, | ||
], | ||
}; | ||
|
||
const result = ControllerUtility.adaptInputToVersion(sourceType, requestVersion, input); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
|
||
// Should return an empty array when the input is an empty array | ||
it('should return an empty array when the input is an empty array', () => { | ||
const sourceType = 'pipedream'; | ||
const requestVersion = 'v1'; | ||
const input = []; | ||
const expected = { implementationVersion: 'v0', input: [] }; | ||
|
||
const result = ControllerUtility.adaptInputToVersion(sourceType, requestVersion, input); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,5 +61,6 @@ | |
"ORTTO": true, | ||
"ONE_SIGNAL": true, | ||
"TIKTOK_AUDIENCE": true | ||
} | ||
}, | ||
"supportSourceTransformV1": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"input": [ | ||
{ | ||
"event": { | ||
"anonymousId": "63767499ca6fb1b7c988d5bb", | ||
"artist": "Gautam", | ||
"genre": "Jazz", | ||
"song": "Take Five" | ||
}, | ||
"source": { | ||
"id": "source_id", | ||
"config": { | ||
"configField1": "configVal1" | ||
} | ||
} | ||
} | ||
], | ||
"output": [ | ||
{ | ||
"statusCode": 500, | ||
"error": "Cannot find module '../undefined/sources/NA_SOURCE/transform' from 'src/services/misc.ts'", | ||
"statTags": { | ||
"errorCategory": "transformation" | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.