Skip to content

Commit

Permalink
chore: fix test cases and adressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anantjain45823 committed Nov 7, 2023
1 parent 26fa7f0 commit 1124fa6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/controllers/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class SourceController {
events,
);
const resplist = await integrationService.sourceTransformRoutine(
input as NonNullable<unknown>[],
input,
source,
implementationVersion,
requestMetadata,
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class ControllerUtility {
};

private static getSourceVersionsMap(): Map<string, any> {
if (this.sourceVersionMap.size > 0) {
if (this.sourceVersionMap?.size > 0) {
return this.sourceVersionMap;
}
const versions = ['v0', 'v1'];
Expand Down
13 changes: 6 additions & 7 deletions src/services/source/nativeIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
RudderMessage,
SourceTransformationResponse,
} from '../../types/index';
import { FixMe } from '../../util/types';
import PostTransformationServiceSource from './postTransformation';
import FetchHandler from '../../helpers/fetchHandlers';
import tags from '../../v0/util/tags';
Expand All @@ -24,23 +25,21 @@ export default class NativeIntegrationSourceService implements IntegrationSource
return metaTO;
}


public async sourceTransformRoutine(
sourceEvents: NonNullable<unknown>[],
sourceType: string,
version: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_requestMetadata: object,
_requestMetadata: NonNullable<unknown>,
): Promise<SourceTransformationResponse[]> {

// Using version along with sourceType because if for a particular
const sourceHandler = FetchHandler.getSourceHandler(sourceType, version);
const respList: SourceTransformationResponse[] = await Promise.all<any>(
const respList: SourceTransformationResponse[] = await Promise.all<FixMe>(
sourceEvents.map(async (sourceEvent) => {
try {
const respEvents: RudderMessage | RudderMessage[] | SourceTransformationResponse = await sourceHandler.process(sourceEvent);
const respEvents: RudderMessage | RudderMessage[] | SourceTransformationResponse =
await sourceHandler.process(sourceEvent);
return PostTransformationServiceSource.handleSuccessEventsSource(respEvents);
} catch (error: any) {
} catch (error: FixMe) {
const metaTO = this.getTags();
stats.increment('source_transform_errors', {
sourceType,
Expand Down
20 changes: 5 additions & 15 deletions test/apitests/data_scenarios/source/v1/failure.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
"input": [
{
"query_parameters": {
"topic": [
"random_event"
],
"signature": [
"rudderstack"
],
"writeKey": [
"sample-write-key"
]
"topic": ["random_event"],
"signature": ["rudderstack"],
"writeKey": ["sample-write-key"]
}
}
],
Expand All @@ -19,12 +13,8 @@
"statusCode": 500,
"error": "Cannot find module '../undefined/sources/NA_SOURCE/transform' from 'src/services/misc.ts'",
"statTags": {
"errorCategory": "transformation",
"module": "source",
"implementation": "native",
"destinationId": "Non determinable",
"workspaceId": "Non determinable"
"errorCategory": "transformation"
}
}
]
}
}

0 comments on commit 1124fa6

Please sign in to comment.