@bugcrowd/briareus
Version:
Briareus assists with Feature Branch deploys to ECS
64 lines (54 loc) • 2.09 kB
JavaScript
const expect = require('expect.js');
const AWS = require('aws-sdk-mock');
const _ = require('lodash');
const helpers = require('../../helpers');
const CreateAlbTargetGroup = require('../../../lib/service/actions/create-alb-target-group');
describe('Action:CreateAlbTargetGroup', function () {
afterEach(helpers.afterEach);
it('should create target group', function (done) {
let targetGroupArn = 'arn:target-group:1';
let payload = {
name: 'briareus-variant',
alb: {
vpcId: 'vpc-1',
},
slug: 'asdf',
webContainerPort: 3000,
healthcheck: {
interval: 20,
path: '/healthcheck',
protocol: 'HTTPS',
timeout: 10,
healthyThreshold: 10,
unhealthyThreshold: 10,
matcherHttpCode: '403'
}
};
AWS.mock('ELBv2', 'createTargetGroup', function (params, cb) {
expect(params.Name).to.equal(payload.name);
expect(params.VpcId).to.equal(payload.alb.vpcId);
expect(params.Protocol).to.equal(payload.healthcheck.protocol);
expect(params.Port).to.equal(payload.webContainerPort);
expect(params.HealthCheckIntervalSeconds).to.equal(payload.healthcheck.interval);
expect(params.HealthCheckPath).to.equal(payload.healthcheck.path);
expect(params.HealthCheckProtocol).to.equal(payload.healthcheck.protocol);
expect(params.HealthCheckTimeoutSeconds).to.equal(payload.healthcheck.timeout);
expect(params.HealthyThresholdCount).to.equal(payload.healthcheck.healthyThreshold);
expect(params.UnhealthyThresholdCount).to.equal(payload.healthcheck.unhealthyThreshold);
expect(params.Matcher).to.eql({
HttpCode: payload.healthcheck.matcherHttpCode
});
cb(null, {
TargetGroups: [
{ TargetGroupArn: targetGroupArn }
]
});
});
CreateAlbTargetGroup({}, payload, (err, patches) => {
expect(err).to.equal(null);
expect(patches[0]).to.eql({ op: 'add', path: '/assets/targetGroup', value: { arn: targetGroupArn } });
done();
})
});
});