heroin-js-librato
Advanced tools
Comparing version 0.2.0 to 0.3.0
const app = require('./lib/app') | ||
const request = require('good-guy-http')({cache: false}) | ||
function client(username, token) { | ||
function client (username, token) { | ||
const librato = require('./lib/libratoClient')(username, token, request) | ||
@@ -6,0 +6,0 @@ return app(librato) |
@@ -8,3 +8,3 @@ const diff = require('./diff') | ||
return this.fetchAllAlerts().then((existingAlerts) => { | ||
const result = diff(existingAlerts, config.alerts) | ||
const result = diff(existingAlerts, config) | ||
const created = result.created | ||
@@ -11,0 +11,0 @@ const updated = result.updated |
{ | ||
"name": "heroin-js-librato", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Librato config as code", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,93 +26,87 @@ const test = require('tape') | ||
configurator.deleteAllAlerts() | ||
.then(() => configurator.fetchAllAlerts()) | ||
.then((result) => { | ||
t.equal(result.length, 0) | ||
}) | ||
.catch((err) => { | ||
console.error(err) | ||
t.fail(err) | ||
}) | ||
.then(() => configurator.fetchAllAlerts()) | ||
.then((result) => { | ||
t.equal(result.length, 0) | ||
}) | ||
.catch((err) => { | ||
console.error(err) | ||
t.fail(err) | ||
}) | ||
}) | ||
withEmptyAlerts( | ||
test('should create a new alert', (t) => { | ||
t.plan(1) | ||
test('should create a new alert', (t) => { | ||
t.plan(1) | ||
configurator.createOrUpdate({ | ||
alerts: [ { | ||
'name': 'myapp.status5xx.high', | ||
'rearm_seconds': 108000, | ||
'conditions': [ { | ||
'type': 'above', | ||
'metric_name': 'router.status.5xx', | ||
'summary_function': 'sum', | ||
'threshold': 40, | ||
'duration': 600 | ||
} ], | ||
'version': 2 | ||
} ] | ||
}).then((result) => t.equal(result, 'modified 1 alerts')) | ||
.catch((err) => { | ||
console.error(err.stack) | ||
t.fail(err) | ||
}) | ||
}) | ||
configurator.createOrUpdate( | ||
[ { | ||
'name': 'myapp.status5xx.high', | ||
'rearm_seconds': 108000, | ||
'conditions': [ { | ||
'type': 'above', | ||
'metric_name': 'router.status.5xx', | ||
'summary_function': 'sum', | ||
'threshold': 40, | ||
'duration': 600 | ||
} ], | ||
'version': 2 | ||
} ] | ||
).then((result) => t.equal(result, 'modified 1 alerts')) | ||
.catch((err) => { | ||
console.error(err.stack) | ||
t.fail(err) | ||
}) | ||
}) | ||
) | ||
withEmptyAlerts( | ||
test('should delete an alert', (t) => { | ||
t.plan(1) | ||
test('should delete an alert', (t) => { | ||
t.plan(1) | ||
configurator.createOrUpdate({ | ||
alerts: [ alertConfig('myapp.test.alert') ] | ||
}).then(() => { | ||
return configurator.createOrUpdate({alerts: []}) | ||
}).then((result) => { | ||
configurator.createOrUpdate( | ||
[ alertConfig('myapp.test.alert') ] | ||
) | ||
.then(() => { | ||
return configurator.createOrUpdate([]) | ||
}) | ||
.then((result) => { | ||
t.equal(result, 'modified 1 alerts') | ||
}) | ||
.catch((err) => { | ||
console.error(err.stack) | ||
t.fail(err) | ||
}) | ||
}) | ||
.catch((err) => { | ||
console.error(err.stack) | ||
t.fail(err) | ||
}) | ||
}) | ||
) | ||
withEmptyAlerts( | ||
test('should batch create alerts', (t) => { | ||
t.plan(1) | ||
test('should batch create alerts', (t) => { | ||
t.plan(1) | ||
configurator.createOrUpdate({ | ||
alerts: [ | ||
alertConfig('myapp.test.alert1'), | ||
alertConfig('myapp.test.alert2') | ||
] | ||
}).then((result) => t.equal(result, 'modified 2 alerts')) | ||
.catch((err) => { | ||
console.error(err) | ||
t.fail(err) | ||
}) | ||
}) | ||
configurator.createOrUpdate([ alertConfig('myapp.test.alert1'), | ||
alertConfig('myapp.test.alert2') ] | ||
).then((result) => t.equal(result, 'modified 2 alerts')) | ||
.catch((err) => { | ||
console.error(err) | ||
t.fail(err) | ||
}) | ||
}) | ||
) | ||
withEmptyAlerts( | ||
test('should batch update alerts', (t) => { | ||
t.plan(1) | ||
test('should batch update alerts', (t) => { | ||
t.plan(1) | ||
configurator.createOrUpdate({ | ||
alerts: [ | ||
alertConfig('myapp.test.alert3'), | ||
alertConfig('myapp.test.alert4'), | ||
alertConfig('myapp.test.alert5') | ||
] | ||
}).then(() => configurator.createOrUpdate({ | ||
alerts: [ | ||
alertConfig('myapp.test.alert3', 2000), | ||
alertConfig('myapp.test.alert4') | ||
] | ||
})).then((result) => t.equal(result, 'modified 2 alerts')) | ||
.catch((err) => { | ||
console.error(err) | ||
t.fail(err) | ||
}) | ||
}) | ||
configurator.createOrUpdate([ alertConfig('myapp.test.alert3'), | ||
alertConfig('myapp.test.alert4'), | ||
alertConfig('myapp.test.alert5') ] | ||
).then(() => configurator.createOrUpdate( | ||
[ alertConfig('myapp.test.alert3', 2000), | ||
alertConfig('myapp.test.alert4') ])) | ||
.then((result) => t.equal(result, 'modified 2 alerts')) | ||
.catch((err) => { | ||
console.error(err) | ||
t.fail(err) | ||
}) | ||
}) | ||
) | ||
@@ -119,0 +113,0 @@ |
@@ -6,4 +6,4 @@ const libratoConfigurator = require('../index').client(process.env.USERNAME, process.env.PASSWORD) | ||
// libratoConfigurator.deleteAllAlerts().then((result) => console.log(result)) | ||
libratoConfigurator.createOrUpdate({ | ||
'alerts': [ | ||
libratoConfigurator.createOrUpdate( | ||
[ | ||
{ | ||
@@ -46,4 +46,4 @@ 'name': 'myapp.test.alert4', | ||
] | ||
}) | ||
) | ||
.then((result) => console.log(result)) | ||
.catch((err) => console.error(err)) |
Sorry, the diff of this file is not supported yet
30188
483