Skip to content

Commit

Permalink
fix(athena): WorkGroup tags corruption (aws#9085)
Browse files Browse the repository at this point in the history
Since Athena does not have AWS constructs the tests are empty. What does
the team think about me adding one test to verify this patch is
correctly applied for the cfn generated constructs?

Can I also get feedback on the file name choice I made or a pointer to
conventions on the patch file names?

Fixes aws#6936

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
moofish32 authored and Curtis Eppel committed Aug 11, 2020
1 parent 91ca9ac commit 4c35fa6
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-athena/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"nodeunit-shim": "0.0.0",
"cfn2ts": "0.0.0",
"pkglint": "0.0.0"
},
Expand Down
72 changes: 69 additions & 3 deletions packages/@aws-cdk/aws-athena/test/athena.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,72 @@
import '@aws-cdk/assert/jest';
import {} from '../lib';
import { expect, haveResource } from '@aws-cdk/assert';
import * as cdk from '@aws-cdk/core';
import { CfnWorkGroup } from '../lib';

test('No tests are specified for this package', () => {
expect(true).toBe(true);
describe('Athena Workgroup Tags', () => {
test('test tag spec correction', () => {
const stack = new cdk.Stack();
new CfnWorkGroup(stack, 'Athena-Workgroup', {
name: 'HelloWorld',
description: 'A WorkGroup',
recursiveDeleteOption: true,
state: 'ENABLED',
tags: [
{
key: 'key1',
value: 'value1',
},
{
key: 'key2',
value: 'value2',
}],
workGroupConfiguration: {
requesterPaysEnabled: true,
resultConfiguration: {
outputLocation: 's3://fakebucketme/athena/results/',
},
},
});
expect(stack).to(haveResource('AWS::Athena::WorkGroup', {
Tags: [
{
Key: 'key1',
Value: 'value1',
},
{
Key: 'key2',
Value: 'value2',
},
],
}));
});
test('test tag aspect spec correction', () => {
const stack = new cdk.Stack();
cdk.Tag.add(stack, 'key1', 'value1');
cdk.Tag.add(stack, 'key2', 'value2');
new CfnWorkGroup(stack, 'Athena-Workgroup', {
name: 'HelloWorld',
description: 'A WorkGroup',
recursiveDeleteOption: true,
state: 'ENABLED',
workGroupConfiguration: {
requesterPaysEnabled: true,
resultConfiguration: {
outputLocation: 's3://fakebucketme/athena/results/',
},
},
});
expect(stack).to(haveResource('AWS::Athena::WorkGroup', {
Tags: [
{
Key: 'key1',
Value: 'value1',
},
{
Key: 'key2',
Value: 'value2',
},
],
}));
});
});
23 changes: 23 additions & 0 deletions packages/@aws-cdk/aws-athena/test/integ.workgroup.expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"Resources": {
"AthenaWorkgroup": {
"Type": "AWS::Athena::WorkGroup",
"Properties": {
"Name": "HelloWorld",
"Description": "A WorkGroup",
"RecursiveDeleteOption": true,
"State": "ENABLED",
"Tags": [
{
"Key": "key1",
"Value": "value1"
},
{
"Key": "key2",
"Value": "value2"
}
]
}
}
}
}
23 changes: 23 additions & 0 deletions packages/@aws-cdk/aws-athena/test/integ.workgroup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as cdk from '@aws-cdk/core';
import { CfnWorkGroup }from '../lib';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-athena-workgroup-tags');

new CfnWorkGroup(stack, 'AthenaWorkgroup', {
name: 'HelloWorld',
description: 'A WorkGroup',
recursiveDeleteOption: true,
state: 'ENABLED',
tags: [
{
key: 'key1',
value: 'value1',
},
{
key: 'key2',
value: 'value2',
}],
});

app.synth();
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"PropertyTypes": {
"AWS::Athena::WorkGroup.Tags": {
"patch": {
"description": "Corrects tag specification for AWS::Athena::WorkGroup.Tags",
"operations": [
{
"op": "remove",
"path": "/Properties"
},
{
"op": "add",
"path": "/ItemType",
"value": "Tag"
},
{
"op": "add",
"path": "/Required",
"value": false
},
{
"op": "add",
"path": "/Type",
"value": "List"
},
{
"op": "add",
"path": "/UpdateType",
"value": "Mutable"
}
]
}
}
}
}

0 comments on commit 4c35fa6

Please sign in to comment.