Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
corymhall committed Nov 18, 2024
1 parent d734186 commit e208e8e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ import { Vpc } from 'aws-cdk-lib/aws-ec2';
import { aws_ssm } from 'aws-cdk-lib';
import { Construct } from 'constructs';

beforeAll(() => {
process.env.AWS_REGION = 'us-east-2';
});
afterAll(() => {
process.env.AWS_REGION = undefined;
});

describe('Basic tests', () => {
setMocks();
test('Checking single resource registration', async () => {
Expand Down
4 changes: 4 additions & 0 deletions tests/cdk-resource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ import { Construct } from 'constructs';
describe('CDK Construct tests', () => {
let resources: MockResourceArgs[] = [];
beforeAll(() => {
process.env.AWS_REGION = 'us-east-2';
resources = [];
setMocks(resources);
});
afterAll(() => {
process.env.AWS_REGION = undefined;
});
// DynamoDB table was previously mapped to the `aws` provider
// otherwise this level of testing wouldn't be necessary.
// We also don't need to do this type of testing for _every_ resource
Expand Down
20 changes: 20 additions & 0 deletions tests/synthesizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import { asNetworkMode, asPlatforms } from '../src/synthesizer';
import { NetworkMode, Platform as DockerPlatform } from '@pulumi/docker-build';
import { DockerImageAsset, Platform, NetworkMode as Network } from 'aws-cdk-lib/aws-ecr-assets';

beforeAll(() => {
process.env.AWS_REGION = 'us-east-2';
});
afterAll(() => {
process.env.AWS_REGION = undefined;
});

describe('Synthesizer File Assets', () => {
test('no assets = no staging resources', async () => {
const resources: MockResourceArgs[] = [];
Expand All @@ -16,6 +23,19 @@ describe('Synthesizer File Assets', () => {
new CfnBucket(scope, 'Bucket');
});
expect(resources).toEqual([
expect.objectContaining({
inputs: {
autoNaming: '{"randomSuffixMinLength":7,"autoTrim":true}',
region: 'us-east-2',
skipCredentialsValidation: 'true',
skipGetEc2Platforms: 'true',
skipMetadataApiCheck: 'true',
skipRegionValidation: 'true',
},
name: 'cdk-aws-native',
provider: '',
type: 'pulumi:providers:aws-native',
}),
expect.objectContaining({
name: 'staging-stack-project-stack',
type: 'cdk:construct:StagingStack',
Expand Down

0 comments on commit e208e8e

Please sign in to comment.