Skip to content

Commit

Permalink
feat(mocks) Added mocks for AmazonServerGroup (#8752)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdk27 committed Nov 30, 2020
1 parent ac2624d commit 096c445
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mocks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spinnaker/mocks",
"version": "1.0.6",
"version": "1.0.7",
"module": "dist/index.js",
"typings": "dist/index.d.ts",
"license": "Apache-2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/mocks/src/amazon/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './mockAmazonBlockDeviceMapping';
export * from './mockAmazonLaunchTemplate';
export * from './mockAmazonServerGroup';
79 changes: 79 additions & 0 deletions packages/mocks/src/amazon/mockAmazonServerGroup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { IAmazonServerGroup, IAmazonAsg, ISuspendedProcess, IAmazonLaunchTemplate } from '@spinnaker/amazon';
import { mockLaunchTemplate } from './mockAmazonLaunchTemplate';

export const mockAmazonAsg: IAmazonAsg = {
minSize: 2,
maxSize: 2,
desiredCapacity: 2,
tags: [],
availabilityZones: ['a', 'b', 'c'],
vpczoneIdentifier: '',
enabledMetrics: [],
suspendedProcesses: [],
};

export const createMockAmazonAsg = (
tags?: any[],
azs?: string[],
suspendedProcesses?: ISuspendedProcess[],
): IAmazonAsg => ({
...mockAmazonAsg,
tags: tags || [],
availabilityZones: azs || ['a', 'b', 'c'],
suspendedProcesses: suspendedProcesses || [],
});

export const createMockAmazonServerGroupWithLc = (
launchConfig?: any,
tags?: any,
asg?: IAmazonAsg,
): IAmazonServerGroup => ({
account: 'test',
app: 'deck',
tags: tags ? tags : [],
category: 'test',
cloudProvider: 'aws',
cluster: 'deck-test',
createdTime: 1578697860003,
instances: [],
instanceType: 't3.micro',
loadBalancers: ['lb-123'],
name: 'deck-test-123',
region: 'us-west-2',
securityGroups: ['sg-abcdefgh'],
stack: 'test',
subnetType: 'ipv4',
type: 'aws',
vpcId: 'vpc-1234abcd',
vpcName: 'test-vpc',

image: 'test-image',
targetGroups: [],
asg: asg || mockAmazonAsg,
launchConfig: launchConfig,
});

export const createMockAmazonServerGroupWithLt = (lt?: IAmazonLaunchTemplate): IAmazonServerGroup => ({
account: 'test',
app: 'deck',
category: 'test',
cloudProvider: 'aws',
cluster: 'deck-test',
createdTime: 1578697860003,
instances: [],
instanceType: 't3.micro',
loadBalancers: ['lb-123'],
name: 'deck-test-123',
region: 'us-west-2',
securityGroups: ['sg-abcdefgh'],
stack: 'test',
subnetType: 'ipv4',
type: 'aws',
vpcId: 'vpc-1234abcd',
vpcName: 'test-vpc',

image: 'test-image',
targetGroups: [],
asg: mockAmazonAsg,
launchTemplate: lt || mockLaunchTemplate,
});

0 comments on commit 096c445

Please sign in to comment.