Skip to content

Commit

Permalink
Merge pull request #904 from RenovoSolutions/ci_fix
Browse files Browse the repository at this point in the history
ci(fix): Fix snapshot testing so asset hash is ignored
  • Loading branch information
bmiller08 authored Nov 13, 2023
2 parents c82a916 + 9db6d9c commit 1f3f300
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const project = new awscdk.AwsCdkConstructLibrary({
deps: [
'@renovosolutions/cdk-library-one-time-event@^2.1.125',
],
bundledDeps: [
'@jest/globals',
],
keywords: [
'letsencrypt',
'certbot',
Expand Down
4 changes: 4 additions & 0 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions test/__snapshots__/certbot.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions test/certbot.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { jest } from '@jest/globals';
import {
aws_s3 as s3,
aws_kms as kms,
Expand All @@ -14,7 +15,7 @@ import {
CertificateStorageType,
} from '../src/index';

jest.setSystemTime(new Date('2020-01-01').getTime());
jest.setSystemTime(new Date('2021-01-15'));

test('Snapshot', () => {
const app = new App();
Expand Down Expand Up @@ -83,7 +84,25 @@ test('Snapshot', () => {
kmsKeyAlias: kmsKeyAlias.aliasName,
});

expect(Template.fromStack(stack)).toMatchSnapshot();
const template = Template.fromStack(stack);

const s = template.findResources('AWS::Lambda::Function', {
Properties: {
Handler: 'index.handler',
},
});

const keys = Object.keys(s);

expect(keys.length).toBe(6);

const json = template.toJSON();

for (const key of keys) {
json.Resources[key].Properties.Code.S3Key = 'REMOVED-BECAUSE-WE-ARE-NOT-INTERESTED-IN-LAMBDA-CODE-HASH-IN-THIS-TEST';
}

expect(json).toMatchSnapshot();
});

test('stack should contain specific number of expected resources when s3 is used', () => {
Expand Down
Loading

0 comments on commit 1f3f300

Please sign in to comment.