Code coverage report for autoScaling/doesAutoScalingGroupExist.js

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

All files » autoScaling/ » doesAutoScalingGroupExist.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 25 26 27    1                         1 2         2       1  
'use strict'
 
var _ = require('lodash')
 
/**
 * Uses AutoScaling.describeAutoScalingGroups to check existence of the
 * auto scaling group. If the list of AutoScalingGroups returned is empty
 * doesAutoScalingGroupExist is resolved as False, if it's not empty it is
 * resolved as True.
 *
 * @param autoScaling
 * @param asgName
 *
 * @returns {Promise}
 */
function doesAutoScalingGroupExist (autoScaling, asgName) {
  return autoScaling
    .describeAutoScalingGroupsPromised({
      AutoScalingGroupNames: [ asgName ]
    })
    .then(function found (data) {
      return !_.isEmpty(data.AutoScalingGroups)
    })
}
 
module.exports = doesAutoScalingGroupExist