-
Notifications
You must be signed in to change notification settings - Fork 0
/
aurora.activity-stream.get-cluster-arn.test.ts
55 lines (47 loc) · 1.46 KB
/
aurora.activity-stream.get-cluster-arn.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { RDSClient, DescribeDBClustersCommand } from '@aws-sdk/client-rds';
import { mockClient } from 'aws-sdk-client-mock';
import sinon from 'sinon';
import { Methods } from '../src/aurora.activity-stream';
sinon.stub(console, 'log');
describe('getClusterArn', () => {
const m = new Methods();
const rdsMock = mockClient(RDSClient);
beforeEach(() => {
rdsMock.reset();
});
it('found', () => {
rdsMock.on(DescribeDBClustersCommand).resolves({
DBClusters: [
{
DBClusterArn: 'arn:aws:rds:us-east-1:123456789012:cluster:aurora-cluster-1',
},
],
});
return m.getClusterArn('aurora-cluster-1').then((result) => {
expect(result).toEqual('arn:aws:rds:us-east-1:123456789012:cluster:aurora-cluster-1');
});
});
it('not found', () => {
rdsMock.on(DescribeDBClustersCommand).resolves({
DBClusters: [],
});
return m.getClusterArn('aurora-cluster-1').then((result) => {
expect(result).toEqual('Not found');
});
});
it('found multiple', () => {
rdsMock.on(DescribeDBClustersCommand).resolves({
DBClusters: [
{
DBClusterArn: 'arn:aws:rds:us-east-1:123456789012:cluster:aurora-cluster-1',
},
{
DBClusterArn: 'arn:aws:rds:us-east-1:123456789012:cluster:aurora-cluster-1',
},
],
});
return m.getClusterArn('aurora-cluster-1').then((result) => {
expect(result).toEqual('Multiple clusters found');
});
});
});