Code coverage report for cloudWatch/doesAlarmExist.js

Statements: 100% (9 / 9)      Branches: 100% (2 / 2)      Functions: 100% (2 / 2)      Lines: 100% (9 / 9)      Ignored: none     

All files » cloudWatch/ » doesAlarmExist.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22    1 1   1 3 1 1     2         2       1  
'use strict'
 
var _ = require('lodash')
var Bluebird = require('bluebird')
 
function doesAlarmExist (cloudWatch, alarmName) {
  if (!_.isString(alarmName)) {
    var err = new TypeError('alarmName is required to be a string')
    return Bluebird.reject(err)
  }
 
  return cloudWatch
    .describeAlarmsPromised({
      AlarmNames: [ alarmName ]
    })
    .then(function (data) {
      return !_.isEmpty(data.MetricAlarms)
    })
}
 
module.exports = doesAlarmExist