Skip to content

Commit

Permalink
add more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlikl committed May 23, 2024
1 parent a5b647d commit 10f64ea
Showing 1 changed file with 81 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ describe('cluster resource provider', () => {
name: 'new-explicit-cluster-name',
roleArn: 'new-arn',
});
});
});
});

test('encryption config cannot be updated', async () => {
Expand Down Expand Up @@ -733,20 +733,99 @@ describe('cluster resource provider', () => {
});
});
describe('tag updates', () => {
test('change of tags', async () => {
test('updates are in-place', async () => {
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Update', {
// this is the new props
...mocks.MOCK_PROPS,
tags: {
foo: 'bar',
hello: 'world',
},
}, {
// this is the old props
...mocks.MOCK_PROPS,
tags: {
foo: 'bar',
},
}));
const resp = await handler.onEvent();
expect(mocks.actualRequest.createClusterRequest).toEqual(undefined);
expect(mocks.actualRequest.tagResourceRequest).toEqual({
resourceArn: 'arn:cluster-arn',
tags: {
hello: 'world',
},
});
expect(mocks.actualRequest.untagResourceRequest).toEqual(undefined);
});
test('update a tag along with a removal', async () => {
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Update', {
// this is the new props
...mocks.MOCK_PROPS,
tags: {
foo: 'world',
},
}, {
// this is the old props
...mocks.MOCK_PROPS,
tags: {
foo: 'bar',
hello: 'world',
},
}));
const resp = await handler.onEvent();
expect(mocks.actualRequest.tagResourceRequest).toEqual({
resourceArn: 'arn:cluster-arn',
tags: {
foo: 'world',
},
});
expect(mocks.actualRequest.untagResourceRequest).toEqual({
resourceArn: 'arn:cluster-arn',
tagKeys: ['hello'],
});
});
test('remove all tags', async () => {
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Update', {
// this is the new props
...mocks.MOCK_PROPS,
}, {
// this is the old props
...mocks.MOCK_PROPS,
tags: {
foo: 'bar',
hello: 'world',
},
}));
const resp = await handler.onEvent();
expect(mocks.actualRequest.tagResourceRequest).toEqual(undefined);
expect(mocks.actualRequest.untagResourceRequest).toEqual({
resourceArn: 'arn:cluster-arn',
tagKeys: ['foo', 'hello'],
});
});
test('add tags after creation of cluster', async () => {
const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Update', {
// this is the new props
...mocks.MOCK_PROPS,
tags: {
foo: 'bar',
hello: 'world',
},
}, {
// this is the old props
...mocks.MOCK_PROPS,
}));
const resp = await handler.onEvent();
expect(mocks.actualRequest.createClusterRequest).toEqual(undefined);
expect(mocks.actualRequest.tagResourceRequest).toEqual({
resourceArn: 'arn:cluster-arn',
tags: {
foo: 'bar',
hello: 'world',
},
});
expect(mocks.actualRequest.untagResourceRequest).toEqual(undefined);
});
});
});
Expand Down

0 comments on commit 10f64ea

Please sign in to comment.