hubot-aws-insight
Version:
A hubot scripts that shows you what's running on aws. Needs Python 3
63 lines (53 loc) • 1.75 kB
JavaScript
;
require('coffee-script/register');
const Helper = require('hubot-test-helper');
const sinon = require('sinon');
const chai = require('chai');
chai.use(require('sinon-chai'));
chai.use(require('chai-wildcard'));
const { expect } = chai;
const fs = require('fs');
sinon.stub(fs, 'writeFile').yields();
const sctiptPath = '../src/aws-insight.js';
const script = require(sctiptPath);
const helper = new Helper(sctiptPath);
describe('AWS Insight', function() {
beforeEach(() => {
this.room = helper.createRoom({
name: 'bob',
});
});
afterEach(() => {
this.room.destroy();
});
it('add account', () =>
this.room.user.say('bob', 'hubot add aws account test 22').then(() => {
expect(this.room.messages[1][1]).to.be.equal('@bob Added the account.');
expect(fs.writeFile).to.have.been.calledTwice;
expect(fs.writeFile.args[0][1])
.to.equal(`---
accounts:
"22":
profile: test`);
expect(fs.writeFile.args[1][1])
.to.equal(`[test]
role_arn = arn:aws:iam::22:role/nilo-role
source_profile = default`);
})
);
it('list accounts', () =>
this.room.user.say('bob', 'hubot add aws account test 22').then(() =>
this.room.user.say('bob', 'hubot list aws accounts')
).then(() =>
expect(this.room.messages[3][1])
.to.be.equal("@bob Here's accounts: { test: 22 }"))
);
it('forget accounts', async () =>
this.room.user.say('bob', 'hubot add aws account test 22').then(() =>
this.room.user.say('bob', 'hubot forget aws account test')).then(() =>
this.room.user.say('bob', 'hubot list aws accounts')).then(() => {
expect(this.room.messages[5][1])
.to.be.equal("@bob Here's accounts: {}");
})
);
});