Skip to content

Commit

Permalink
feat: Track number of users invited to Slack #195 (#196)
Browse files Browse the repository at this point in the history
Add `invitedUserCount` to Slack config.
  • Loading branch information
blefebvre committed Mar 25, 2024
1 parent 6e58ac9 commit e808a42
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const configSchema = Joi.object({
slack: Joi.object({
workspace: Joi.string(),
channel: Joi.string(),
invitedUserCount: Joi.number().integer().min(0),
}),
alerts: Joi.array().items(Joi.object({
type: Joi.string().required(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Config Tests', () => {
slack: {
channel: 'channel1',
workspace: 'workspace1',
invitedUserCount: 3,
},
alerts: [{
type: '404',
Expand All @@ -55,6 +56,7 @@ describe('Config Tests', () => {
const config = Config(data);
expect(config.slack.channel).to.equal('channel1');
expect(config.slack.workspace).to.equal('workspace1');
expect(config.slack.invitedUserCount).to.equal(3);
expect(config.alerts[0].mentions[0].slack[0]).to.equal('id1');
expect(config.alerts[0].byOrg).to.be.true;
expect(config.audits.auditsDisabled()).to.be.false;
Expand All @@ -67,6 +69,7 @@ describe('Config Tests', () => {
slack: {
channel: 'channel1',
workspace: 'workspace1',
invitedUserCount: 19,
},
alerts: [{
type: '404',
Expand All @@ -78,6 +81,7 @@ describe('Config Tests', () => {
const config = Config(data);
expect(config.slack.channel).to.equal('channel1');
expect(config.slack.workspace).to.equal('workspace1');
expect(config.slack.invitedUserCount).to.equal(19);
expect(config.alerts[0].mentions[0].slack[0]).to.equal('id1');
expect(config.alerts[0].byOrg).to.be.true;
expect(config.audits.auditsDisabled()).to.be.false;
Expand All @@ -97,6 +101,17 @@ describe('Config Tests', () => {
};
expect(() => Config(data)).to.throw('Configuration validation error: "alerts[0].type" must be a string');
});

it('throws an error when invitedUserCount is invalid', () => {
const data = {
slack: {
channel: 'channel1',
workspace: 'workspace1',
invitedUserCount: -12,
},
};
expect(() => Config(data)).to.throw('Configuration validation error: "slack.invitedUserCount" must be greater than or equal to 0');
});
});

describe('fromDynamoItem Static Method', () => {
Expand Down

0 comments on commit e808a42

Please sign in to comment.