Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelManke committed Feb 9, 2024
1 parent 76d83a2 commit 8588356
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 8 additions & 1 deletion packages/@aws-cdk/aws-pipes-sources-alpha/lib/sqs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,30 @@ export class SqsSource implements ISource {
private readonly queue: IQueue;
readonly sourceArn;
private sourceParameters;

constructor(queue: IQueue, parameters?: SqsSourceParameters) {
this.queue = queue;
this.sourceArn = queue.queueArn;
if (parameters) {
this.sourceParameters = parameters;
}
}

bind(_pipe: IPipe): SourceConfig {
if (!this.sourceParameters) {
return {};
}

return {
sourceParameters: {
sqsQueueParameters: this.sourceParameters && {
sqsQueueParameters: {
batchSize: this.sourceParameters?.batchSize,
maximumBatchingWindowInSeconds: this.sourceParameters?.maximumBatchingWindow?.toSeconds(),
},
},
};
}

grantRead(grantee: IRole): void {
this.queue.grantConsumeMessages(grantee);
}
Expand Down
6 changes: 2 additions & 4 deletions packages/@aws-cdk/aws-pipes-sources-alpha/test/sqs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TestTarget } from './test-classes';
import { SqsSource } from '../lib';

describe('sqs', () => {
it('should have source arn', () => {
it('should have only source arn', () => {
// ARRANGE
const app = new App();
const stack = new Stack(app, 'TestStack');
Expand All @@ -31,8 +31,8 @@ describe('sqs', () => {
'Arn',
],
},
SourceParameters: {},
});

});

it('should have source parameters', () => {
Expand Down Expand Up @@ -64,7 +64,6 @@ describe('sqs', () => {
},
},
});

});

it('should grant pipe role read access', () => {
Expand All @@ -87,6 +86,5 @@ describe('sqs', () => {
// ASSERT
expect(template.findResources('AWS::IAM::Role')).toMatchSnapshot();
expect(template.findResources('AWS::IAM::Policy')).toMatchSnapshot();

});
});

0 comments on commit 8588356

Please sign in to comment.