Skip to content

Commit

Permalink
[#153] Rename applyCommon
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangmirs committed Aug 17, 2023
1 parent 930ada5 commit e802536
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/templates/addons/aws/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { remove } from '@/helpers/file';
import { generateAwsTemplate } from '.';
import { applyAdvancedTemplate } from './advanced';
import {
applyCommon,
applyTerraformAWS,
applyRegion,
applySecurityGroup,
applyVpc,
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('AWS template', () => {
});

it('applies common add-on', () => {
expect(applyCommon).toHaveBeenCalledWith(awsOptions);
expect(applyTerraformAWS).toHaveBeenCalledWith(awsOptions);
});

it('applies region add-on', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GeneralOptions } from '@/commands/generate';
import { applyAdvancedTemplate } from './advanced';
import { AWS_DEFAULT_REGION } from './constants';
import {
applyCommon,
applyTerraformAWS,
applyIamUserAndGroup,
applyRegion,
applySecurityGroup,
Expand Down Expand Up @@ -44,7 +44,7 @@ type AwsOptions = GeneralOptions & {
};

const applyCommonModules = async (options: AwsOptions) => {
await applyCommon(options);
await applyTerraformAWS(options);
await applyRegion(options);
};

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/alb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import applyAlb, {
albSGOutputsContent,
albVariablesContent,
} from './alb';
import applyCommon from './core/common';
import applyTerraformAWS from './core/common';

jest.mock('inquirer', () => {
return {
Expand All @@ -29,7 +29,7 @@ describe('ALB add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applyAlb(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/bastion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import applyBastion, {
bastionSGOutputsContent,
bastionVariablesContent,
} from './bastion';
import applyCommon from './core/common';
import applyTerraformAWS from './core/common';

jest.mock('inquirer', () => {
return {
Expand All @@ -28,7 +28,7 @@ describe('Bastion add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applyBastion(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/cloudwatch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import applyCloudwatch, {
cloudwatchModuleContent,
cloudwatchVariablesContent,
} from './cloudwatch';
import applyCommon from './core/common';
import applyTerraformAWS from './core/common';

jest.mock('inquirer', () => {
return {
Expand All @@ -26,7 +26,7 @@ describe('Cloudwatch add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applyCloudwatch(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/core/common.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';

import applyCommon from './common';
import applyTerraformAWS from './common';

describe('Common add-on', () => {
describe('given valid AwsOptions', () => {
Expand All @@ -14,7 +14,7 @@ describe('Common add-on', () => {
infrastructureType: 'advanced',
};

await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
});

afterAll(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/core/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AwsOptions } from '@/templates/addons/aws';
import { AWS_SKELETON_PATH } from '@/templates/addons/aws/constants';
import { INFRA_BASE_PATH, INFRA_SHARED_PATH } from '@/templates/core/constants';

const applyCommon = async (options: AwsOptions) => {
const applyTerraformAWS = async (options: AwsOptions) => {
copy(
`${AWS_SKELETON_PATH}/providers.tf`,
`${INFRA_BASE_PATH}/providers.tf`,
Expand All @@ -16,4 +16,4 @@ const applyCommon = async (options: AwsOptions) => {
);
};

export default applyCommon;
export default applyTerraformAWS;
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/core/iamUserAndGroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyTerraformCore } from '@/templates/core';

import applyCommon from './common';
import applyTerraformAWS from './common';
import applyIamUserAndGroup, {
iamVariablesContent,
iamGroupsModuleContent,
Expand All @@ -23,7 +23,7 @@ describe('IAM add-on', () => {
};

applyTerraformCore(awsOptions);
applyCommon(awsOptions);
applyTerraformAWS(awsOptions);
applyIamUserAndGroup(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/core/region.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyTerraformCore } from '@/templates/core';

import applyCommon from './common';
import applyTerraformAWS from './common';
import applyRegion, { regionVariablesContent } from './region';

jest.mock('inquirer', () => {
Expand All @@ -25,7 +25,7 @@ describe('Region add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applyRegion(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/core/securityGroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyTerraformCore } from '@/templates/core';

import applyCommon from './common';
import applyTerraformAWS from './common';
import applySecurityGroup, {
securityGroupModuleContent,
securityGroupVariablesContent,
Expand All @@ -26,7 +26,7 @@ describe('Security group add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applySecurityGroup(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/core/vpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyTerraformCore } from '@/templates/core';

import applyCommon from './common';
import applyTerraformAWS from './common';
import applyVpc, { vpcModuleContent, vpcOutputsContent } from './vpc';

describe('VPC add-on', () => {
Expand All @@ -17,7 +17,7 @@ describe('VPC add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applyVpc(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/ecr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyTerraformCore } from '@/templates/core';

import applyCommon from './core/common';
import applyTerraformAWS from './core/common';
import applyEcr, { ecrModuleContent, ecrVariablesContent } from './ecr';

jest.mock('inquirer', () => {
Expand All @@ -23,7 +23,7 @@ describe('ECR add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applyEcr(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/ecs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyTerraformCore } from '@/templates/core';

import applyCommon from './core/common';
import applyTerraformAWS from './core/common';
import applyEcs, {
ecsModuleContent,
ecsSGMainContent,
Expand All @@ -28,7 +28,7 @@ describe('ECS add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applyEcs(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import applyAlb from './alb';
import applyBastion from './bastion';
import applyCloudwatch from './cloudwatch';
import applyCommon from './core/common';
import applyTerraformAWS from './core/common';
import applyIamUserAndGroup from './core/iamUserAndGroup';
import applyRegion from './core/region';
import applySecurityGroup from './core/securityGroup';
Expand All @@ -15,7 +15,7 @@ import applySsm from './ssm';
export {
applyAlb,
applyBastion,
applyCommon,
applyTerraformAWS,
applyCloudwatch,
applyEcr,
applyEcs,
Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/rds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyTerraformCore } from '@/templates/core';

import applyCommon from './core/common';
import applyTerraformAWS from './core/common';
import applyRds, {
rdsModuleContent,
rdsSGMainContent,
Expand All @@ -28,7 +28,7 @@ describe('RDS add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applyRds(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/s3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyTerraformCore } from '@/templates/core';

import applyCommon from './core/common';
import applyTerraformAWS from './core/common';
import applyS3, { s3ModuleContent, s3OutputsContent } from './s3';

jest.mock('inquirer', () => {
Expand All @@ -23,7 +23,7 @@ describe('S3 add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applyS3(awsOptions);
});

Expand Down
4 changes: 2 additions & 2 deletions src/templates/addons/aws/modules/ssm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyTerraformCore } from '@/templates/core';

import applyCommon from './core/common';
import applyTerraformAWS from './core/common';
import applySsm, { ssmModuleContent, ssmVariablesContent } from './ssm';

jest.mock('inquirer', () => {
Expand All @@ -23,7 +23,7 @@ describe('SSM add-on', () => {
};

await applyTerraformCore(awsOptions);
await applyCommon(awsOptions);
await applyTerraformAWS(awsOptions);
await applySsm(awsOptions);
});

Expand Down
12 changes: 6 additions & 6 deletions src/templates/core/dependencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { prompt } from 'inquirer';

import { remove } from '@/helpers/file';
import { AwsOptions } from '@/templates/addons/aws';
import { applyCommon, applyVpc } from '@/templates/addons/aws/modules';
import { applyTerraformAWS, applyVpc } from '@/templates/addons/aws/modules';

import { applyTerraformCore } from '.';
import { isAWSModuleAdded, requireAWSModules } from './dependencies';
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('Dependencies', () => {
};

await applyTerraformCore(options);
await applyCommon(options);
await applyTerraformAWS(options);
await applyVpc(options);

expect(await requireAWSModules('alb', 'vpc', options)).toBe(true);
Expand All @@ -88,7 +88,7 @@ describe('Dependencies', () => {
};

await applyTerraformCore(options);
await applyCommon(options);
await applyTerraformAWS(options);

(prompt as unknown as jest.Mock).mockResolvedValue({
apply: true,
Expand All @@ -107,7 +107,7 @@ describe('Dependencies', () => {
};

await applyTerraformCore(options);
await applyCommon(options);
await applyTerraformAWS(options);

(prompt as unknown as jest.Mock).mockResolvedValue({
apply: false,
Expand All @@ -131,7 +131,7 @@ describe('Dependencies', () => {
};

await applyTerraformCore(options);
await applyCommon(options);
await applyTerraformAWS(options);

expect(
await requireAWSModules('alb', 'vpc', options, {
Expand All @@ -151,7 +151,7 @@ describe('Dependencies', () => {
};

await applyTerraformCore(options);
await applyCommon(options);
await applyTerraformAWS(options);
await applyVpc(options);

await expect(
Expand Down

0 comments on commit e802536

Please sign in to comment.