Code coverage report for autoScaling/doesScalingPolicyExist.js

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

All files » autoScaling/ » doesScalingPolicyExist.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24    1 1   1 3 1         2           2       1  
'use strict'
 
var _ = require('lodash')
var Bluebird = require('bluebird')
 
function doesScalingPolicyExist (autoScaling, policyName, asgName) {
  if (!_.isString(policyName)) {
    return Bluebird.reject(
      new TypeError('policyName is required to be a string')
    )
  }
 
  return autoScaling
    .describePoliciesPromised({
      AutoScalingGroupName: asgName,
      PolicyNames: [policyName]
    })
    .then(function (data) {
      return !_.isEmpty(data.ScalingPolicies)
    })
}
 
module.exports = doesScalingPolicyExist