-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
147 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { AwsOptions } from '.'; | ||
import { remove } from '../../helpers/file'; | ||
import { | ||
applyAlb, | ||
applyBastion, | ||
applyCommon, | ||
applyEcr, | ||
applyEcs, | ||
applyLog, | ||
applyRds, | ||
applyRegion, | ||
applyS3, | ||
applySecurityGroup, | ||
applySsm, | ||
applyVpc, | ||
} from './addons'; | ||
import { applyAdvancedTemplate } from './advanced'; | ||
|
||
jest.mock('./addons'); | ||
|
||
describe('AWS advanced template', () => { | ||
describe('applyAdvancedTemplate', () => { | ||
const projectDir = 'aws-advanced-test'; | ||
const options: AwsOptions = { projectName: projectDir, provider: 'aws', infrastructureType: 'advanced', awsRegion: 'ap-southeast-1' }; | ||
|
||
beforeAll(() => { | ||
applyAdvancedTemplate(options); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
remove('/', projectDir); | ||
}); | ||
|
||
it('applies common add-on', () => { | ||
expect(applyCommon).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies region add-on', () => { | ||
expect(applyRegion).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies VPC add-on', () => { | ||
expect(applyVpc).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies security group add-on', () => { | ||
expect(applySecurityGroup).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies ECR add-on', () => { | ||
expect(applyEcr).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies log add-on', () => { | ||
expect(applyLog).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies S3 add-on', () => { | ||
expect(applyS3).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies ALB add-on', () => { | ||
expect(applyAlb).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies RDS add-on', () => { | ||
expect(applyRds).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies bastion add-on', () => { | ||
expect(applyBastion).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies SSM add-on', () => { | ||
expect(applySsm).toHaveBeenCalledWith(options); | ||
}); | ||
|
||
it('applies ECS add-on', () => { | ||
expect(applyEcs).toHaveBeenCalledWith(options); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { prompt } from 'inquirer'; | ||
|
||
import { generateAwsTemplate } from '.'; | ||
import { GeneralOptions } from '../../commands/generate'; | ||
import { remove } from '../../helpers/file'; | ||
import { applyAdvancedTemplate } from './advanced'; | ||
|
||
jest.mock('./advanced'); | ||
jest.mock('inquirer'); | ||
|
||
describe('AWS template', () => { | ||
describe('generateAwsTemplate', () => { | ||
const projectDir = 'aws-advanced-test'; | ||
const options: GeneralOptions = { projectName: projectDir, provider: 'aws' }; | ||
|
||
describe('given infrastructureType is basic', () => { | ||
beforeAll(() => { | ||
(prompt as unknown as jest.Mock) | ||
.mockResolvedValueOnce({ infrastructureType: 'basic' }); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
remove('/', projectDir); | ||
}); | ||
|
||
it('throws the error message', async() => { | ||
await expect(generateAwsTemplate(options)).rejects.toThrow('This type has not been implemented!'); | ||
}); | ||
}); | ||
|
||
describe('given infrastructureType is advanced', () => { | ||
beforeAll(() => { | ||
(prompt as unknown as jest.Mock) | ||
.mockResolvedValueOnce({ infrastructureType: 'advanced' }); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
remove('/', projectDir); | ||
}); | ||
|
||
it('applies advanced add-ons', async() => { | ||
await generateAwsTemplate(options); | ||
|
||
expect(applyAdvancedTemplate).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
}); |