feat: fully functioning ALB
This commit is contained in:
@@ -18,6 +18,7 @@ const baseInstance: Ec2Instance = {
|
||||
architecture: 'x86_64',
|
||||
platform: undefined,
|
||||
securityGroups: [{id: 'sg-abc', name: 'default'}],
|
||||
networkInterfaces: [],
|
||||
tags: [{key: 'Name', value: 'web-server-1'}],
|
||||
}
|
||||
|
||||
@@ -25,14 +26,12 @@ function fakeService(overrides: Partial<{
|
||||
listInstances: () => Promise<Ec2Instance[]>
|
||||
describeInstance: (id: string) => Promise<Ec2Instance>
|
||||
terminateInstance: (id: string) => Promise<void>
|
||||
listAmis: () => Promise<[]>
|
||||
runInstance: (input: RunInstanceInput) => Promise<Ec2Instance>
|
||||
}> = {}) {
|
||||
return {
|
||||
listInstances: async () => [baseInstance],
|
||||
describeInstance: async (_id: string) => baseInstance,
|
||||
terminateInstance: async (_id: string) => {},
|
||||
listAmis: async () => [] as [],
|
||||
runInstance: async (_input: RunInstanceInput) => baseInstance,
|
||||
...overrides,
|
||||
}
|
||||
@@ -80,6 +79,20 @@ describe('AwsComputeAdapter', () => {
|
||||
expect(result).toHaveLength(2)
|
||||
})
|
||||
|
||||
test('list filters instances by their EC2 lifecycle state', async () => {
|
||||
const adapter = new AwsComputeAdapter(fakeService({
|
||||
listInstances: async () => [
|
||||
baseInstance,
|
||||
{...baseInstance, instanceId: 'i-stopped', state: 'stopped'},
|
||||
],
|
||||
}))
|
||||
|
||||
const result = await adapter.list({state: 'stopped'})
|
||||
|
||||
expect(result).toHaveLength(1)
|
||||
expect(result[0]).toMatchObject({id: 'i-stopped', status: 'stopped', type: 'instance'})
|
||||
})
|
||||
|
||||
test('get returns null when instance has 404 http status', async () => {
|
||||
const err = Object.assign(new Error('Not found'), {$metadata: {httpStatusCode: 404}})
|
||||
const adapter = new AwsComputeAdapter(fakeService({
|
||||
|
||||
Reference in New Issue
Block a user