Skip to content

Commit

Permalink
Fix previous tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Sep 15, 2020
1 parent 8a88c9e commit b955b72
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
38 changes: 14 additions & 24 deletions lib/plugins/aws/package/compile/events/msk/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

const chai = require('chai');
const runServerless = require('../../../../../../../test/utils/run-serverless');
const fixtures = require('../../../../../../../test/fixtures');

const { expect } = chai;

chai.use(require('chai-as-promised'));

describe('AwsCompileMSKEvents', () => {
after(fixtures.cleanup);

const arn = 'arn:aws:kafka:us-east-1:111111111111:cluster/ClusterName/a1a1a1a1a1a1a1a1a';
const topic = 'TestingTopic';
const enabled = false;
Expand All @@ -24,8 +21,9 @@ describe('AwsCompileMSKEvents', () => {
let naming;

before(() =>
fixtures
.extend('function', {
runServerless({
fixture: 'function',
configExt: {
functions: {
foo: {
events: [
Expand All @@ -51,24 +49,16 @@ describe('AwsCompileMSKEvents', () => {
],
},
},
})
.then(fixturePath =>
runServerless({
cwd: fixturePath,
cliArgs: ['package'],
}).then(({ awsNaming, cfTemplate }) => {
naming = awsNaming;
minimalEventSourceMappingResource =
cfTemplate.Resources[
naming.getMSKEventLogicalId('foo', 'ClusterName', 'TestingTopic')
];
allParamsEventSourceMappingResource =
cfTemplate.Resources[
naming.getMSKEventLogicalId('other', 'ClusterName', 'TestingTopic')
];
defaultIamRole = cfTemplate.Resources.IamRoleLambdaExecution;
})
)
},
cliArgs: ['package'],
}).then(({ awsNaming, cfTemplate }) => {
naming = awsNaming;
minimalEventSourceMappingResource =
cfTemplate.Resources[naming.getMSKEventLogicalId('foo', 'ClusterName', 'TestingTopic')];
allParamsEventSourceMappingResource =
cfTemplate.Resources[naming.getMSKEventLogicalId('other', 'ClusterName', 'TestingTopic')];
defaultIamRole = cfTemplate.Resources.IamRoleLambdaExecution;
})
);

it('should correctly compile EventSourceMapping resource properties with minimal configuration', () => {
Expand Down Expand Up @@ -127,7 +117,7 @@ describe('AwsCompileMSKEvents', () => {
describe('when no msk events are defined', () => {
it('should not modify the default IAM role', () => {
return runServerless({
cwd: fixtures.map.function,
fixture: 'function',
cliArgs: ['package'],
}).then(({ cfTemplate }) => {
const defaultIamRole = cfTemplate.Resources.IamRoleLambdaExecution;
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/functionMsk/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// eslint-disable-next-line
const { log } = require('./utils');

// NOTE: `kafkajs` is bundled into the deployment package
// eslint-disable-next-line
const { Kafka } = require('kafkajs');

function consumer(event, context, callback) {
Expand Down

0 comments on commit b955b72

Please sign in to comment.