Skip to content

Commit

Permalink
Add more testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
nakedible-p authored Oct 4, 2023
1 parent d308053 commit fc9f3b1
Showing 1 changed file with 81 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('Start Query Execution', () => {
});
});

test('execution parameters', () => {
test('execution parameters succeeds', () => {
// GIVEN
const stack = new cdk.Stack();

Expand Down Expand Up @@ -278,4 +278,84 @@ describe('Start Query Execution', () => {
},
});
});

test('execution parameters succeeds with token', () => {
// GIVEN
const stack = new cdk.Stack();

// WHEN
const task = new AthenaStartQueryExecution(stack, 'Query', {
queryString: 'CREATE DATABASE ?',
clientRequestToken: 'unique-client-request-token',
queryExecutionContext: {
databaseName: 'mydatabase',
catalogName: 'AwsDataCatalog',
},
resultConfiguration: {
outputLocation: {
bucketName: 'query-results-bucket',
objectKey: 'folder',
},
},
workGroup: 'primary',
executionParameters: sfn.JsonPath.listAt('$.executionParameters'),
});

// THEN
expect(stack.resolve(task.toStateJson())).toEqual({
Type: 'Task',
Resource: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':states:::athena:startQueryExecution',
],
],
},
End: true,
Parameters: {
'QueryString': 'CREATE DATABASE ?',
'ClientRequestToken': 'unique-client-request-token',
'QueryExecutionContext': {
Database: 'mydatabase',
Catalog: 'AwsDataCatalog',
},
'ResultConfiguration': {
OutputLocation: 's3://query-results-bucket/folder/',
},
'WorkGroup': 'primary',
'ExecutionParameters.$': '$.executionParameters',
},
});
});

test('execution parameters fails on invalid values', () => {
// GIVEN
const stack = new cdk.Stack();

expect(() => {
// WHEN
const task = new AthenaStartQueryExecution(stack, 'Query', {
queryString: 'CREATE DATABASE ?',
clientRequestToken: 'unique-client-request-token',
queryExecutionContext: {
databaseName: 'mydatabase',
catalogName: 'AwsDataCatalog',
},
resultConfiguration: {
outputLocation: {
bucketName: 'query-results-bucket',
objectKey: 'folder',
},
},
workGroup: 'primary',
executionParameters: ['valid1', 'database'.repeat(129), 'valid2'],
});
// THEN
}).toThrow(/length must be between 1 and 1024 characters/);
});
});

0 comments on commit fc9f3b1

Please sign in to comment.