diff --git a/.eslintrc.yml b/.eslintrc.yml index bed57fbc..65f1dce6 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -11,3 +11,4 @@ rules: block-scoped-var: error eqeqeq: error no-warning-comments: warn + no-var: error diff --git a/samples/mailjet.js b/samples/mailjet.js index ab368694..ece5d102 100644 --- a/samples/mailjet.js +++ b/samples/mailjet.js @@ -16,10 +16,10 @@ 'use strict'; // [START send] -var mailer = require('nodemailer'); -var smtp = require('nodemailer-smtp-transport'); +let mailer = require('nodemailer'); +let smtp = require('nodemailer-smtp-transport'); -var transport = mailer.createTransport( +let transport = mailer.createTransport( smtp({ host: 'in.mailjet.com', port: 2525, diff --git a/samples/sendgrid.js b/samples/sendgrid.js index 95f87370..79ad26e7 100644 --- a/samples/sendgrid.js +++ b/samples/sendgrid.js @@ -15,11 +15,11 @@ // [START send] // This sample is based off of https://www.npmjs.com/package/sendgrid#without-mail-helper-class -var Sendgrid = require('sendgrid')( +let Sendgrid = require('sendgrid')( process.env.SENDGRID_API_KEY || '' ); -var request = Sendgrid.emptyRequest({ +let request = Sendgrid.emptyRequest({ method: 'POST', path: '/v3/mail/send', body: { diff --git a/samples/startup-script/system-test/index.test.js b/samples/startup-script/system-test/index.test.js index 719b4718..55f1c654 100644 --- a/samples/startup-script/system-test/index.test.js +++ b/samples/startup-script/system-test/index.test.js @@ -35,7 +35,7 @@ test.cb(`should list vms`, t => { }); test.cb(`should create vm`, t => { - var TESTS_PREFIX = 'gcloud-tests-'; + let TESTS_PREFIX = 'gcloud-tests-'; const name = generateName('vm-with-apache'); function generateName(customPrefix) { diff --git a/src/address.js b/src/address.js index 74c756af..8c0a6205 100644 --- a/src/address.js +++ b/src/address.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /** * An Address object allows you to interact with a Google Compute Engine @@ -37,7 +37,7 @@ var util = require('util'); * const address = region.address('address1'); */ function Address(region, name) { - var methods = { + let methods = { /** * Create an address. * @@ -216,7 +216,7 @@ util.inherits(Address, common.ServiceObject); Address.prototype.delete = function(callback) { callback = callback || common.util.noop; - var region = this.region; + let region = this.region; this.request( { @@ -229,7 +229,7 @@ Address.prototype.delete = function(callback) { return; } - var operation = region.operation(resp.name); + let operation = region.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/autoscaler.js b/src/autoscaler.js index 1c29d3b1..9a27e25e 100644 --- a/src/autoscaler.js +++ b/src/autoscaler.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /*! Developer Documentation * @@ -41,7 +41,7 @@ var util = require('util'); * const autoscaler = zone.autoscaler('autoscaler-name'); */ function Autoscaler(zone, name) { - var methods = { + let methods = { /** * Create an autoscaler. * @@ -231,7 +231,7 @@ util.inherits(Autoscaler, common.ServiceObject); Autoscaler.prototype.delete = function(callback) { callback = callback || common.util.noop; - var zone = this.zone; + let zone = this.zone; common.ServiceObject.prototype.delete.call(this, function(err, resp) { if (err) { @@ -239,7 +239,7 @@ Autoscaler.prototype.delete = function(callback) { return; } - var operation = zone.operation(resp.name); + let operation = zone.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); @@ -283,7 +283,7 @@ Autoscaler.prototype.delete = function(callback) { * }); */ Autoscaler.prototype.setMetadata = function(metadata, callback) { - var zone = this.zone; + let zone = this.zone; callback = callback || common.util.noop; @@ -306,7 +306,7 @@ Autoscaler.prototype.setMetadata = function(metadata, callback) { return; } - var operation = zone.operation(resp.name); + let operation = zone.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/disk.js b/src/disk.js index 9cce1409..75f6c799 100644 --- a/src/disk.js +++ b/src/disk.js @@ -16,13 +16,13 @@ 'use strict'; -var common = require('@google-cloud/common'); -var extend = require('extend'); -var format = require('string-format-obj'); -var is = require('is'); -var util = require('util'); +let common = require('@google-cloud/common'); +let extend = require('extend'); +let format = require('string-format-obj'); +let is = require('is'); +let util = require('util'); -var Snapshot = require('./snapshot.js'); +let Snapshot = require('./snapshot.js'); /** * A Disk object allows you to interact with a Google Compute Engine disk. @@ -41,7 +41,7 @@ var Snapshot = require('./snapshot.js'); * const disk = zone.disk('disk1'); */ function Disk(zone, name) { - var methods = { + let methods = { /** * Create a persistent disk. * @@ -261,8 +261,8 @@ Disk.formatName_ = function(zone, name) { * }); */ Disk.prototype.createSnapshot = function(name, options, callback) { - var self = this; - var zone = this.zone; + let self = this; + let zone = this.zone; if (is.fn(options)) { callback = options; @@ -283,9 +283,9 @@ Disk.prototype.createSnapshot = function(name, options, callback) { return; } - var snapshot = self.snapshot(name); + let snapshot = self.snapshot(name); - var operation = zone.operation(resp.name); + let operation = zone.operation(resp.name); operation.metadata = resp; callback(null, snapshot, operation, resp); @@ -324,7 +324,7 @@ Disk.prototype.createSnapshot = function(name, options, callback) { * }); */ Disk.prototype.delete = function(callback) { - var zone = this.zone; + let zone = this.zone; callback = callback || common.util.noop; @@ -334,7 +334,7 @@ Disk.prototype.delete = function(callback) { return; } - var operation = zone.operation(resp.name); + let operation = zone.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/firewall.js b/src/firewall.js index dacf7f29..c1cf60be 100644 --- a/src/firewall.js +++ b/src/firewall.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /** * A Firewall object allows you to interact with a Google Compute Engine @@ -36,7 +36,7 @@ var util = require('util'); * const firewall = compute.firewall('tcp-3000'); */ function Firewall(compute, name) { - var methods = { + let methods = { /** * Create a firewall. * @@ -222,7 +222,7 @@ util.inherits(Firewall, common.ServiceObject); * }); */ Firewall.prototype.delete = function(callback) { - var compute = this.compute; + let compute = this.compute; callback = callback || common.util.noop; @@ -232,7 +232,7 @@ Firewall.prototype.delete = function(callback) { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); @@ -275,7 +275,7 @@ Firewall.prototype.delete = function(callback) { * }); */ Firewall.prototype.setMetadata = function(metadata, callback) { - var compute = this.compute; + let compute = this.compute; callback = callback || common.util.noop; @@ -295,7 +295,7 @@ Firewall.prototype.setMetadata = function(metadata, callback) { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/health-check.js b/src/health-check.js index 4dc46203..3c89d125 100644 --- a/src/health-check.js +++ b/src/health-check.js @@ -16,10 +16,10 @@ 'use strict'; -var common = require('@google-cloud/common'); -var extend = require('extend'); -var is = require('is'); -var util = require('util'); +let common = require('@google-cloud/common'); +let extend = require('extend'); +let is = require('is'); +let util = require('util'); /** * Health checks ensure that Compute Engine forwards new connections only to @@ -44,7 +44,7 @@ var util = require('util'); * const healthCheck = gce.healthCheck('health-check-name'); */ function HealthCheck(compute, name, options) { - var methods = { + let methods = { /** * Create an HTTP or HTTPS health check. * @@ -167,7 +167,7 @@ function HealthCheck(compute, name, options) { options = options || {}; - var https = options.https; + let https = options.https; /** * The parent {@link Compute} instance of this {@link HealthCheck} instance. @@ -231,7 +231,7 @@ util.inherits(HealthCheck, common.ServiceObject); * }); */ HealthCheck.prototype.delete = function(callback) { - var compute = this.compute; + let compute = this.compute; callback = callback || common.util.noop; @@ -241,7 +241,7 @@ HealthCheck.prototype.delete = function(callback) { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); @@ -286,11 +286,11 @@ HealthCheck.prototype.delete = function(callback) { * }); */ HealthCheck.prototype.setMetadata = function(metadata, callback) { - var compute = this.compute; + let compute = this.compute; callback = callback || common.util.noop; - var setMetadata = common.ServiceObject.prototype.setMetadata; + let setMetadata = common.ServiceObject.prototype.setMetadata; setMetadata.call(this, metadata, function(err, resp) { if (err) { @@ -298,7 +298,7 @@ HealthCheck.prototype.setMetadata = function(metadata, callback) { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/image.js b/src/image.js index 28896904..f18b670b 100644 --- a/src/image.js +++ b/src/image.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /** * An Image object allows you to interact with a Google Compute Engine image. @@ -35,7 +35,7 @@ var util = require('util'); * const image = compute.image('image-name'); */ function Image(compute, name) { - var methods = { + let methods = { /** * Create an image. * @@ -194,7 +194,7 @@ util.inherits(Image, common.ServiceObject); * }); */ Image.prototype.delete = function(callback) { - var compute = this.parent; + let compute = this.parent; callback = callback || common.util.noop; @@ -204,7 +204,7 @@ Image.prototype.delete = function(callback) { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/index.js b/src/index.js index 4784970e..21858a10 100644 --- a/src/index.js +++ b/src/index.js @@ -16,24 +16,24 @@ 'use strict'; -var arrify = require('arrify'); -var common = require('@google-cloud/common'); -var extend = require('extend'); -var format = require('string-format-obj'); -var is = require('is'); -var util = require('util'); - -var Firewall = require('./firewall.js'); -var HealthCheck = require('./health-check.js'); -var Network = require('./network.js'); -var Operation = require('./operation.js'); -var Project = require('./project.js'); -var Region = require('./region.js'); -var Rule = require('./rule.js'); -var Service = require('./service.js'); -var Snapshot = require('./snapshot.js'); -var Zone = require('./zone.js'); -var Image = require('./image.js'); +let arrify = require('arrify'); +let common = require('@google-cloud/common'); +let extend = require('extend'); +let format = require('string-format-obj'); +let is = require('is'); +let util = require('util'); + +let Firewall = require('./firewall.js'); +let HealthCheck = require('./health-check.js'); +let Network = require('./network.js'); +let Operation = require('./operation.js'); +let Project = require('./project.js'); +let Region = require('./region.js'); +let Rule = require('./rule.js'); +let Service = require('./service.js'); +let Snapshot = require('./snapshot.js'); +let Zone = require('./zone.js'); +let Image = require('./image.js'); /** * @typedef {object} ClientConfig @@ -81,7 +81,7 @@ var Image = require('./image.js'); function Compute(options) { options = common.util.normalizeArguments(this, options); - var config = { + let config = { baseUrl: 'https://www.googleapis.com/compute/v1', scopes: ['https://www.googleapis.com/auth/compute'], packageJson: require('../package.json'), @@ -151,7 +151,7 @@ util.inherits(Compute, common.Service); * }); */ Compute.prototype.createFirewall = function(name, config, callback) { - var self = this; + let self = this; if (!is.string(name)) { throw new Error('A firewall name must be provided.'); @@ -161,19 +161,19 @@ Compute.prototype.createFirewall = function(name, config, callback) { throw new Error('A firewall configuration object must be provided.'); } - var body = extend({}, config, { + let body = extend({}, config, { name: name, }); if (body.protocols) { body.allowed = arrify(body.allowed); - for (var protocol in body.protocols) { - var allowedConfig = { + for (let protocol in body.protocols) { + let allowedConfig = { IPProtocol: protocol, }; - var ports = body.protocols[protocol]; + let ports = body.protocols[protocol]; if (ports === false || ports.length === 0) { continue; @@ -210,9 +210,9 @@ Compute.prototype.createFirewall = function(name, config, callback) { return; } - var firewall = self.firewall(name); + let firewall = self.firewall(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, firewall, operation, resp); @@ -268,7 +268,7 @@ Compute.prototype.createFirewall = function(name, config, callback) { * }); */ Compute.prototype.createHealthCheck = function(name, options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -279,11 +279,11 @@ Compute.prototype.createHealthCheck = function(name, options, callback) { throw new Error('A health check name must be provided.'); } - var body = extend({}, options, { + let body = extend({}, options, { name: name, }); - var https = options.https; + let https = options.https; delete body.https; if (body.interval) { @@ -308,11 +308,11 @@ Compute.prototype.createHealthCheck = function(name, options, callback) { return; } - var healthCheck = self.healthCheck(name, { + let healthCheck = self.healthCheck(name, { https: https, }); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, healthCheck, operation, resp); @@ -355,7 +355,7 @@ Compute.prototype.createHealthCheck = function(name, options, callback) { * }); */ Compute.prototype.createImage = function(name, disk, options, callback) { - var self = this; + let self = this; if (!common.util.isCustomType(disk, 'Disk')) { throw new Error('A Disk object is required.'); @@ -366,7 +366,7 @@ Compute.prototype.createImage = function(name, disk, options, callback) { options = {}; } - var body = extend( + let body = extend( { name: name, sourceDisk: format('zones/{zoneName}/disks/{diskName}', { @@ -388,9 +388,9 @@ Compute.prototype.createImage = function(name, disk, options, callback) { callback(err, null, resp); return; } - var image = self.image(name); + let image = self.image(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, image, operation, resp); @@ -445,9 +445,9 @@ Compute.prototype.createImage = function(name, disk, options, callback) { * }); */ Compute.prototype.createNetwork = function(name, config, callback) { - var self = this; + let self = this; - var body = extend({}, config, { + let body = extend({}, config, { name: name, }); @@ -473,9 +473,9 @@ Compute.prototype.createNetwork = function(name, config, callback) { return; } - var network = self.network(name); + let network = self.network(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, network, operation, resp); @@ -542,9 +542,9 @@ Compute.prototype.createNetwork = function(name, config, callback) { * }); */ Compute.prototype.createRule = function(name, config, callback) { - var self = this; + let self = this; - var body = extend({}, config, { + let body = extend({}, config, { name: name, }); @@ -575,9 +575,9 @@ Compute.prototype.createRule = function(name, config, callback) { return; } - var rule = self.rule(name); + let rule = self.rule(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, rule, operation, resp); @@ -633,9 +633,9 @@ Compute.prototype.createRule = function(name, config, callback) { * }); */ Compute.prototype.createService = function(name, config, callback) { - var self = this; + let self = this; - var body = extend({}, config, { + let body = extend({}, config, { name: name, }); @@ -651,9 +651,9 @@ Compute.prototype.createService = function(name, config, callback) { return; } - var service = self.service(name); + let service = self.service(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, service, operation, resp); @@ -734,7 +734,7 @@ Compute.prototype.firewall = function(name) { * }); */ Compute.prototype.getAddresses = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -754,7 +754,7 @@ Compute.prototype.getAddresses = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -762,14 +762,14 @@ Compute.prototype.getAddresses = function(options, callback) { }); } - var regions = resp.items || {}; + let regions = resp.items || {}; - var addresses = Object.keys(regions).reduce(function(acc, regionName) { - var region = self.region(regionName.replace('regions/', '')); - var regionAddresses = regions[regionName].addresses || []; + let addresses = Object.keys(regions).reduce(function(acc, regionName) { + let region = self.region(regionName.replace('regions/', '')); + let regionAddresses = regions[regionName].addresses || []; regionAddresses.forEach(function(address) { - var addressInstance = region.address(address.name); + let addressInstance = region.address(address.name); addressInstance.metadata = address; acc.push(addressInstance); }); @@ -868,7 +868,7 @@ Compute.prototype.getAddressesStream = common.paginator.streamify( * }); */ Compute.prototype.getAutoscalers = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -888,7 +888,7 @@ Compute.prototype.getAutoscalers = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -896,18 +896,18 @@ Compute.prototype.getAutoscalers = function(options, callback) { }); } - var zones = resp.items || {}; + let zones = resp.items || {}; - var autoscalers = Object.keys(zones).reduce(function(acc, zoneName) { + let autoscalers = Object.keys(zones).reduce(function(acc, zoneName) { if (zoneName.indexOf('zones/') !== 0) { return acc; } - var zone = self.zone(zoneName.replace('zones/', '')); - var zoneAutoscalers = zones[zoneName].autoscalers || []; + let zone = self.zone(zoneName.replace('zones/', '')); + let zoneAutoscalers = zones[zoneName].autoscalers || []; zoneAutoscalers.forEach(function(autoscaler) { - var autoscalerInstance = zone.autoscaler(autoscaler.name); + let autoscalerInstance = zone.autoscaler(autoscaler.name); autoscalerInstance.metadata = autoscaler; acc.push(autoscalerInstance); }); @@ -1005,7 +1005,7 @@ Compute.prototype.getAutoscalersStream = common.paginator.streamify( * }); */ Compute.prototype.getDisks = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1025,7 +1025,7 @@ Compute.prototype.getDisks = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1033,14 +1033,14 @@ Compute.prototype.getDisks = function(options, callback) { }); } - var zones = resp.items || {}; + let zones = resp.items || {}; - var disks = Object.keys(zones).reduce(function(acc, zoneName) { - var zone = self.zone(zoneName.replace('zones/', '')); - var disks = zones[zoneName].disks || []; + let disks = Object.keys(zones).reduce(function(acc, zoneName) { + let zone = self.zone(zoneName.replace('zones/', '')); + let disks = zones[zoneName].disks || []; disks.forEach(function(disk) { - var diskInstance = zone.disk(disk.name); + let diskInstance = zone.disk(disk.name); diskInstance.metadata = disk; acc.push(diskInstance); }); @@ -1138,7 +1138,7 @@ Compute.prototype.getDisksStream = common.paginator.streamify('getDisks'); * }); */ Compute.prototype.getInstanceGroups = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1158,7 +1158,7 @@ Compute.prototype.getInstanceGroups = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1166,14 +1166,14 @@ Compute.prototype.getInstanceGroups = function(options, callback) { }); } - var zones = resp.items || {}; + let zones = resp.items || {}; - var instanceGroups = Object.keys(zones).reduce(function(acc, zoneName) { - var zone = self.zone(zoneName.replace('zones/', '')); - var instanceGroups = zones[zoneName].instanceGroups || []; + let instanceGroups = Object.keys(zones).reduce(function(acc, zoneName) { + let zone = self.zone(zoneName.replace('zones/', '')); + let instanceGroups = zones[zoneName].instanceGroups || []; instanceGroups.forEach(function(group) { - var instanceGroupInstance = zone.instanceGroup(group.name); + let instanceGroupInstance = zone.instanceGroup(group.name); instanceGroupInstance.metadata = group; acc.push(instanceGroupInstance); }); @@ -1270,7 +1270,7 @@ Compute.prototype.getInstanceGroupsStream = common.paginator.streamify( * }); */ Compute.prototype.getFirewalls = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1290,7 +1290,7 @@ Compute.prototype.getFirewalls = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1298,8 +1298,8 @@ Compute.prototype.getFirewalls = function(options, callback) { }); } - var firewalls = (resp.items || []).map(function(firewall) { - var firewallInstance = self.firewall(firewall.name); + let firewalls = (resp.items || []).map(function(firewall) { + let firewallInstance = self.firewall(firewall.name); firewallInstance.metadata = firewall; return firewallInstance; }); @@ -1394,7 +1394,7 @@ Compute.prototype.getFirewallsStream = common.paginator.streamify( * }); */ Compute.prototype.getHealthChecks = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1403,7 +1403,7 @@ Compute.prototype.getHealthChecks = function(options, callback) { options = extend({}, options); - var https = options.https; + let https = options.https; delete options.https; this.request( @@ -1417,7 +1417,7 @@ Compute.prototype.getHealthChecks = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1425,8 +1425,8 @@ Compute.prototype.getHealthChecks = function(options, callback) { }); } - var healthChecks = (resp.items || []).map(function(healthCheck) { - var healthCheckInstance = self.healthCheck(healthCheck.name, { + let healthChecks = (resp.items || []).map(function(healthCheck) { + let healthCheckInstance = self.healthCheck(healthCheck.name, { https: https, }); healthCheckInstance.metadata = healthCheck; @@ -1520,7 +1520,7 @@ Compute.prototype.getHealthChecksStream = common.paginator.streamify( * }); */ Compute.prototype.getImages = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1540,7 +1540,7 @@ Compute.prototype.getImages = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1548,8 +1548,8 @@ Compute.prototype.getImages = function(options, callback) { }); } - var images = (resp.items || []).map(function(image) { - var imageInstance = self.image(image.name); + let images = (resp.items || []).map(function(image) { + let imageInstance = self.image(image.name); imageInstance.metadata = image; return imageInstance; }); @@ -1644,7 +1644,7 @@ Compute.prototype.getImagesStream = common.paginator.streamify('getImages'); * }); */ Compute.prototype.getMachineTypes = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1664,7 +1664,7 @@ Compute.prototype.getMachineTypes = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1672,14 +1672,14 @@ Compute.prototype.getMachineTypes = function(options, callback) { }); } - var zones = resp.items || {}; + let zones = resp.items || {}; - var machineTypes = Object.keys(zones).reduce(function(acc, zoneName) { - var zone = self.zone(zoneName.replace('zones/', '')); - var machineTypesByZone = zones[zoneName].machineTypes || []; + let machineTypes = Object.keys(zones).reduce(function(acc, zoneName) { + let zone = self.zone(zoneName.replace('zones/', '')); + let machineTypesByZone = zones[zoneName].machineTypes || []; machineTypesByZone.forEach(function(machineType) { - var machineTypeInstance = zone.machineType(machineType.name); + let machineTypeInstance = zone.machineType(machineType.name); machineTypeInstance.metadata = machineType; acc.push(machineTypeInstance); }); @@ -1778,7 +1778,7 @@ Compute.prototype.getMachineTypesStream = common.paginator.streamify( * }); */ Compute.prototype.getNetworks = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1798,7 +1798,7 @@ Compute.prototype.getNetworks = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1806,8 +1806,8 @@ Compute.prototype.getNetworks = function(options, callback) { }); } - var networks = (resp.items || []).map(function(network) { - var networkInstance = self.network(network.name); + let networks = (resp.items || []).map(function(network) { + let networkInstance = self.network(network.name); networkInstance.metadata = network; return networkInstance; }); @@ -1900,7 +1900,7 @@ Compute.prototype.getNetworksStream = common.paginator.streamify('getNetworks'); * }); */ Compute.prototype.getOperations = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1920,7 +1920,7 @@ Compute.prototype.getOperations = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1928,8 +1928,8 @@ Compute.prototype.getOperations = function(options, callback) { }); } - var operations = (resp.items || []).map(function(operation) { - var operationInstance = self.operation(operation.name); + let operations = (resp.items || []).map(function(operation) { + let operationInstance = self.operation(operation.name); operationInstance.metadata = operation; return operationInstance; }); @@ -2025,7 +2025,7 @@ Compute.prototype.getOperationsStream = common.paginator.streamify( * }); */ Compute.prototype.getRegions = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -2043,7 +2043,7 @@ Compute.prototype.getRegions = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -2051,8 +2051,8 @@ Compute.prototype.getRegions = function(options, callback) { }); } - var regions = resp.items.map(function(region) { - var regionInstance = self.region(region.name); + let regions = resp.items.map(function(region) { + let regionInstance = self.region(region.name); regionInstance.metadata = region; return regionInstance; }); @@ -2145,7 +2145,7 @@ Compute.prototype.getRegionsStream = common.paginator.streamify('getRegions'); * }); */ Compute.prototype.getRules = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -2165,7 +2165,7 @@ Compute.prototype.getRules = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -2173,8 +2173,8 @@ Compute.prototype.getRules = function(options, callback) { }); } - var rules = (resp.items || []).map(function(rule) { - var ruleInstance = self.rule(rule.name); + let rules = (resp.items || []).map(function(rule) { + let ruleInstance = self.rule(rule.name); ruleInstance.metadata = rule; return ruleInstance; }); @@ -2267,7 +2267,7 @@ Compute.prototype.getRulesStream = common.paginator.streamify('getRules'); * }); */ Compute.prototype.getServices = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -2287,7 +2287,7 @@ Compute.prototype.getServices = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -2295,8 +2295,8 @@ Compute.prototype.getServices = function(options, callback) { }); } - var services = (resp.items || []).map(function(service) { - var serviceInstance = self.service(service.name); + let services = (resp.items || []).map(function(service) { + let serviceInstance = self.service(service.name); serviceInstance.metadata = service; return serviceInstance; }); @@ -2389,7 +2389,7 @@ Compute.prototype.getServicesStream = common.paginator.streamify('getServices'); * }); */ Compute.prototype.getSnapshots = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -2409,7 +2409,7 @@ Compute.prototype.getSnapshots = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -2417,8 +2417,8 @@ Compute.prototype.getSnapshots = function(options, callback) { }); } - var snapshots = (resp.items || []).map(function(snapshot) { - var snapshotInstance = self.snapshot(snapshot.name); + let snapshots = (resp.items || []).map(function(snapshot) { + let snapshotInstance = self.snapshot(snapshot.name); snapshotInstance.metadata = snapshot; return snapshotInstance; }); @@ -2513,7 +2513,7 @@ Compute.prototype.getSnapshotsStream = common.paginator.streamify( * }); */ Compute.prototype.getSubnetworks = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -2533,7 +2533,7 @@ Compute.prototype.getSubnetworks = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -2541,14 +2541,14 @@ Compute.prototype.getSubnetworks = function(options, callback) { }); } - var regions = resp.items || {}; + let regions = resp.items || {}; - var subnetworks = Object.keys(regions).reduce(function(acc, regionName) { - var region = self.region(regionName.replace('regions/', '')); - var subnetworks = regions[regionName].subnetworks || []; + let subnetworks = Object.keys(regions).reduce(function(acc, regionName) { + let region = self.region(regionName.replace('regions/', '')); + let subnetworks = regions[regionName].subnetworks || []; subnetworks.forEach(function(subnetwork) { - var subnetworkInstance = region.subnetwork(subnetwork.name); + let subnetworkInstance = region.subnetwork(subnetwork.name); subnetworkInstance.metadata = subnetwork; acc.push(subnetworkInstance); }); @@ -2646,7 +2646,7 @@ Compute.prototype.getSubnetworksStream = common.paginator.streamify( * }); */ Compute.prototype.getVMs = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -2666,7 +2666,7 @@ Compute.prototype.getVMs = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -2674,14 +2674,14 @@ Compute.prototype.getVMs = function(options, callback) { }); } - var zones = resp.items || {}; + let zones = resp.items || {}; - var vms = Object.keys(zones).reduce(function(acc, zoneName) { - var zone = self.zone(zoneName.replace('zones/', '')); - var instances = zones[zoneName].instances || []; + let vms = Object.keys(zones).reduce(function(acc, zoneName) { + let zone = self.zone(zoneName.replace('zones/', '')); + let instances = zones[zoneName].instances || []; instances.forEach(function(instance) { - var vmInstance = zone.vm(instance.name); + let vmInstance = zone.vm(instance.name); vmInstance.metadata = instance; acc.push(vmInstance); }); @@ -2777,7 +2777,7 @@ Compute.prototype.getVMsStream = common.paginator.streamify('getVMs'); * }); */ Compute.prototype.getZones = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -2795,7 +2795,7 @@ Compute.prototype.getZones = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -2803,8 +2803,8 @@ Compute.prototype.getZones = function(options, callback) { }); } - var zones = resp.items.map(function(zone) { - var zoneInstance = self.zone(zone.name); + let zones = resp.items.map(function(zone) { + let zoneInstance = self.zone(zone.name); zoneInstance.metadata = zone; return zoneInstance; }); @@ -3012,8 +3012,8 @@ Compute.prototype.zone = function(name) { Compute.prototype.execAfterOperation_ = function(callback) { return function(err) { // arguments = [..., op, apiResponse] - var operation = arguments[arguments.length - 2]; - var apiResponse = arguments[arguments.length - 1]; + let operation = arguments[arguments.length - 2]; + let apiResponse = arguments[arguments.length - 1]; if (err) { callback(err, apiResponse); diff --git a/src/instance-group.js b/src/instance-group.js index bcaa45dd..f444a112 100644 --- a/src/instance-group.js +++ b/src/instance-group.js @@ -16,11 +16,11 @@ 'use strict'; -var arrify = require('arrify'); -var common = require('@google-cloud/common'); -var extend = require('extend'); -var is = require('is'); -var util = require('util'); +let arrify = require('arrify'); +let common = require('@google-cloud/common'); +let extend = require('extend'); +let is = require('is'); +let util = require('util'); /** * You can create and manage groups of virtual machine instances so that you @@ -40,7 +40,7 @@ var util = require('util'); * const instanceGroup = zone.instanceGroup('web-servers'); */ function InstanceGroup(zone, name) { - var methods = { + let methods = { /** * Create an instance group. * @@ -249,7 +249,7 @@ InstanceGroup.formatPorts_ = function(ports) { * }); */ InstanceGroup.prototype.add = function(vms, callback) { - var self = this; + let self = this; this.request( { @@ -269,7 +269,7 @@ InstanceGroup.prototype.add = function(vms, callback) { return; } - var operation = self.zone.operation(resp.name); + let operation = self.zone.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); @@ -308,7 +308,7 @@ InstanceGroup.prototype.add = function(vms, callback) { * }); */ InstanceGroup.prototype.delete = function(callback) { - var self = this; + let self = this; callback = callback || common.util.noop; @@ -318,7 +318,7 @@ InstanceGroup.prototype.delete = function(callback) { return; } - var operation = self.zone.operation(resp.name); + let operation = self.zone.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); @@ -384,7 +384,7 @@ InstanceGroup.prototype.delete = function(callback) { * }); */ InstanceGroup.prototype.getVMs = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -393,7 +393,7 @@ InstanceGroup.prototype.getVMs = function(options, callback) { options = options || {}; - var body; + let body; if (options.running) { body = { @@ -414,7 +414,7 @@ InstanceGroup.prototype.getVMs = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -422,8 +422,8 @@ InstanceGroup.prototype.getVMs = function(options, callback) { }); } - var vms = arrify(resp.items).map(function(vm) { - var vmInstance = self.zone.vm(vm.instance); + let vms = arrify(resp.items).map(function(vm) { + let vmInstance = self.zone.vm(vm.instance); vmInstance.metadata = vm; return vmInstance; }); @@ -505,7 +505,7 @@ InstanceGroup.prototype.getVMsStream = common.paginator.streamify('getVMs'); * }); */ InstanceGroup.prototype.remove = function(vms, callback) { - var self = this; + let self = this; this.request( { @@ -525,7 +525,7 @@ InstanceGroup.prototype.remove = function(vms, callback) { return; } - var operation = self.zone.operation(resp.name); + let operation = self.zone.operation(resp.name); operation.metadata = resp; callback(err, operation, resp); @@ -571,7 +571,7 @@ InstanceGroup.prototype.remove = function(vms, callback) { * }); */ InstanceGroup.prototype.setPorts = function(ports, callback) { - var self = this; + let self = this; callback = callback || common.util.noop; @@ -589,7 +589,7 @@ InstanceGroup.prototype.setPorts = function(ports, callback) { return; } - var operation = self.zone.operation(resp.name); + let operation = self.zone.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/machine-type.js b/src/machine-type.js index 30801a3d..bbd2587e 100644 --- a/src/machine-type.js +++ b/src/machine-type.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /** * A MachineType object allows you to interact with a Google Compute Engine @@ -37,7 +37,7 @@ var util = require('util'); * const machineType = zone.machineType('g1-small'); */ function MachineType(zone, name) { - var methods = { + let methods = { /** * Check if the machine type exists. * diff --git a/src/network.js b/src/network.js index 3789c2b2..35ed4999 100644 --- a/src/network.js +++ b/src/network.js @@ -16,11 +16,11 @@ 'use strict'; -var common = require('@google-cloud/common'); -var extend = require('extend'); -var format = require('string-format-obj'); -var is = require('is'); -var util = require('util'); +let common = require('@google-cloud/common'); +let extend = require('extend'); +let format = require('string-format-obj'); +let is = require('is'); +let util = require('util'); /** * A Network object allows you to interact with a Google Compute Engine network. @@ -38,7 +38,7 @@ var util = require('util'); * const network = compute.network('network-name'); */ function Network(compute, name) { - var methods = { + let methods = { /** * Create a network. * @@ -331,7 +331,7 @@ Network.prototype.createSubnetwork = function(name, config, callback) { network: this.formattedName, }); - var region = config.region; + let region = config.region; if (is.string(region)) { region = this.compute.region(region); @@ -481,7 +481,7 @@ Network.prototype.getSubnetworksStream = function(options) { * }); */ Network.prototype.delete = function(callback) { - var compute = this.compute; + let compute = this.compute; callback = callback || common.util.noop; @@ -491,7 +491,7 @@ Network.prototype.delete = function(callback) { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); @@ -512,7 +512,7 @@ Network.prototype.delete = function(callback) { * const firewall = network.firewall('firewall-name'); */ Network.prototype.firewall = function(name) { - var firewall = this.compute.firewall(name); + let firewall = this.compute.firewall(name); firewall.metadata = { network: this.formattedName, diff --git a/src/operation.js b/src/operation.js index abbf4c99..4014ee6e 100644 --- a/src/operation.js +++ b/src/operation.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /** * An Operation object allows you to interact with a Google Compute Engine @@ -87,9 +87,9 @@ var util = require('util'); * operation.removeAllListeners(); */ function Operation(scope, name) { - var isCompute = scope.constructor.name === 'Compute'; + let isCompute = scope.constructor.name === 'Compute'; - var methods = { + let methods = { /** * Delete the operation. * @@ -219,11 +219,11 @@ util.inherits(Operation, common.Operation); * }); */ Operation.prototype.getMetadata = function(callback) { - var self = this; + let self = this; callback = callback || common.util.noop; - var getMetadata = common.ServiceObject.prototype.getMetadata; + let getMetadata = common.ServiceObject.prototype.getMetadata; getMetadata.call(this, function(err, apiResponse) { // An Operation entity contains a property named `error`. This makes @@ -231,7 +231,7 @@ Operation.prototype.getMetadata = function(callback) { // this callback. We have to make sure this isn't a false error by seeing if // the response body contains a property that wouldn't exist on a failed API // request (`name`). - var requestFailed = err && (!apiResponse || apiResponse.name !== self.name); + let requestFailed = err && (!apiResponse || apiResponse.name !== self.name); if (requestFailed) { callback(err, null, apiResponse); @@ -254,12 +254,12 @@ Operation.prototype.getMetadata = function(callback) { * @private */ Operation.prototype.poll_ = function(callback) { - var self = this; + let self = this; this.getMetadata(function(err, metadata, apiResponse) { // Parsing the response body will automatically create an ApiError object if // the operation failed. - var parsedHttpRespBody = common.util.parseHttpRespBody(apiResponse); + let parsedHttpRespBody = common.util.parseHttpRespBody(apiResponse); err = err || parsedHttpRespBody.err; if (err) { diff --git a/src/project.js b/src/project.js index df44b73e..b334125b 100644 --- a/src/project.js +++ b/src/project.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /** * A Project object allows you to interact with your Google Compute Engine @@ -41,7 +41,7 @@ function Project(compute) { */ this.id = compute.projectId; - var methods = { + let methods = { /** * Get a Project object. * diff --git a/src/region.js b/src/region.js index c75c555e..16a5b61b 100644 --- a/src/region.js +++ b/src/region.js @@ -16,16 +16,16 @@ 'use strict'; -var common = require('@google-cloud/common'); -var extend = require('extend'); -var is = require('is'); -var util = require('util'); +let common = require('@google-cloud/common'); +let extend = require('extend'); +let is = require('is'); +let util = require('util'); -var Address = require('./address.js'); -var Network = require('./network.js'); -var Operation = require('./operation.js'); -var Rule = require('./rule.js'); -var Subnetwork = require('./subnetwork.js'); +let Address = require('./address.js'); +let Network = require('./network.js'); +let Operation = require('./operation.js'); +let Rule = require('./rule.js'); +let Subnetwork = require('./subnetwork.js'); /** * A Region object allows you to interact with a Google Compute Engine region. @@ -43,7 +43,7 @@ var Subnetwork = require('./subnetwork.js'); * const region = compute.region('us-central1'); */ function Region(compute, name) { - var methods = { + let methods = { /** * Check if the region exists. * @@ -214,7 +214,7 @@ Region.prototype.address = function(name) { * }); */ Region.prototype.createAddress = function(name, options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -235,9 +235,9 @@ Region.prototype.createAddress = function(name, options, callback) { return; } - var address = self.address(name); + let address = self.address(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, address, operation, resp); @@ -298,9 +298,9 @@ Region.prototype.createAddress = function(name, options, callback) { * }); */ Region.prototype.createSubnetwork = function(name, config, callback) { - var self = this; + let self = this; - var body = extend({}, config, { + let body = extend({}, config, { name: name, }); @@ -325,9 +325,9 @@ Region.prototype.createSubnetwork = function(name, config, callback) { return; } - var subnetwork = self.subnetwork(name); + let subnetwork = self.subnetwork(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, subnetwork, operation, resp); @@ -458,7 +458,7 @@ Region.prototype.createRule = function(name, config, callback) { * }); */ Region.prototype.getAddresses = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -478,7 +478,7 @@ Region.prototype.getAddresses = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -486,8 +486,8 @@ Region.prototype.getAddresses = function(options, callback) { }); } - var addresses = (resp.items || []).map(function(address) { - var addressInstance = self.address(address.name); + let addresses = (resp.items || []).map(function(address) { + let addressInstance = self.address(address.name); addressInstance.metadata = address; return addressInstance; }); @@ -590,7 +590,7 @@ Region.prototype.getAddressesStream = common.paginator.streamify( * }); */ Region.prototype.getOperations = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -610,7 +610,7 @@ Region.prototype.getOperations = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -618,8 +618,8 @@ Region.prototype.getOperations = function(options, callback) { }); } - var operations = (resp.items || []).map(function(operation) { - var operationInstance = self.operation(operation.name); + let operations = (resp.items || []).map(function(operation) { + let operationInstance = self.operation(operation.name); operationInstance.metadata = operation; return operationInstance; }); @@ -721,7 +721,7 @@ Region.prototype.getOperationsStream = common.paginator.streamify( * }); */ Region.prototype.getRules = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -741,7 +741,7 @@ Region.prototype.getRules = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -749,8 +749,8 @@ Region.prototype.getRules = function(options, callback) { }); } - var rules = (resp.items || []).map(function(rule) { - var ruleInstance = self.rule(rule.name); + let rules = (resp.items || []).map(function(rule) { + let ruleInstance = self.rule(rule.name); ruleInstance.metadata = rule; return ruleInstance; }); @@ -851,7 +851,7 @@ Region.prototype.getRulesStream = common.paginator.streamify('getRules'); * }); */ Region.prototype.getSubnetworks = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -871,7 +871,7 @@ Region.prototype.getSubnetworks = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -879,8 +879,8 @@ Region.prototype.getSubnetworks = function(options, callback) { }); } - var subnetworks = (resp.items || []).map(function(subnetwork) { - var subnetworkInstance = self.subnetwork(subnetwork.name); + let subnetworks = (resp.items || []).map(function(subnetwork) { + let subnetworkInstance = self.subnetwork(subnetwork.name); subnetworkInstance.metadata = subnetwork; return subnetworkInstance; }); diff --git a/src/rule.js b/src/rule.js index d73897e8..b56e07d0 100644 --- a/src/rule.js +++ b/src/rule.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /** * Forwarding rules work in conjunction with target pools and target instances @@ -49,9 +49,9 @@ var util = require('util'); * const rule = region.rule('rule-name'); */ function Rule(scope, name) { - var isGlobalRule = scope.constructor.name === 'Compute'; + let isGlobalRule = scope.constructor.name === 'Compute'; - var methods = { + let methods = { /** * Create a forwarding rule. * @@ -234,7 +234,7 @@ util.inherits(Rule, common.ServiceObject); Rule.prototype.delete = function(callback) { callback = callback || common.util.noop; - var scope = this.scope; + let scope = this.scope; common.ServiceObject.prototype.delete.call(this, function(err, resp) { if (err) { @@ -242,7 +242,7 @@ Rule.prototype.delete = function(callback) { return; } - var operation = scope.operation(resp.name); + let operation = scope.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); @@ -285,7 +285,7 @@ Rule.prototype.delete = function(callback) { Rule.prototype.setTarget = function(target, callback) { callback = callback || common.util.noop; - var scope = this.scope; + let scope = this.scope; this.request( { @@ -301,7 +301,7 @@ Rule.prototype.setTarget = function(target, callback) { return; } - var operation = scope.operation(resp.name); + let operation = scope.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/service.js b/src/service.js index a8e04a19..50f15bde 100644 --- a/src/service.js +++ b/src/service.js @@ -16,11 +16,11 @@ 'use strict'; -var arrify = require('arrify'); -var common = require('@google-cloud/common'); -var format = require('string-format-obj'); -var is = require('is'); -var util = require('util'); +let arrify = require('arrify'); +let common = require('@google-cloud/common'); +let format = require('string-format-obj'); +let is = require('is'); +let util = require('util'); /** * An HTTP(S) load balancing backend service is a centralized service for @@ -44,7 +44,7 @@ var util = require('util'); * const service = const.service('service-name'); */ function Service(compute, name) { - var methods = { + let methods = { /** * Create a backend service. * @@ -231,7 +231,7 @@ util.inherits(Service, common.ServiceObject); * }); */ Service.prototype.delete = function(callback) { - var compute = this.compute; + let compute = this.compute; callback = callback || common.util.noop; @@ -241,7 +241,7 @@ Service.prototype.delete = function(callback) { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); @@ -360,7 +360,7 @@ Service.prototype.getHealth = function(group, callback) { * }); */ Service.prototype.setMetadata = function(metadata, callback) { - var compute = this.compute; + let compute = this.compute; callback = callback || common.util.noop; @@ -376,7 +376,7 @@ Service.prototype.setMetadata = function(metadata, callback) { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/snapshot.js b/src/snapshot.js index bccfa9cd..acd2de77 100644 --- a/src/snapshot.js +++ b/src/snapshot.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /** * A Snapshot object allows you to interact with a Google Compute Engine @@ -43,9 +43,9 @@ var util = require('util'); * const snapshot = disk.snapshot('disk-snapshot-name'); */ function Snapshot(scope, name) { - var isDisk = scope.constructor.name === 'Disk'; + let isDisk = scope.constructor.name === 'Disk'; - var methods = { + let methods = { /** * Check if the snapshot exists. * @@ -127,7 +127,7 @@ function Snapshot(scope, name) { getMetadata: true, }; - var config = { + let config = { parent: scope, baseUrl: 'https://www.googleapis.com/compute/v1/projects/{{projectId}}/global/snapshots', @@ -223,7 +223,7 @@ util.inherits(Snapshot, common.ServiceObject); Snapshot.prototype.delete = function(callback) { callback = callback || common.util.noop; - var compute = this.compute; + let compute = this.compute; common.ServiceObject.prototype.delete.call(this, function(err, resp) { if (err) { @@ -231,7 +231,7 @@ Snapshot.prototype.delete = function(callback) { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/subnetwork.js b/src/subnetwork.js index 7ab996a5..65ea509f 100644 --- a/src/subnetwork.js +++ b/src/subnetwork.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +let common = require('@google-cloud/common'); +let util = require('util'); /** * An Subnetwork object allows you to interact with a Google Compute Engine @@ -49,7 +49,7 @@ function Subnetwork(region, name) { */ this.region = region; - var methods = { + let methods = { /** * Create a subnetwork. * @@ -221,7 +221,7 @@ util.inherits(Subnetwork, common.ServiceObject); Subnetwork.prototype.delete = function(callback) { callback = callback || common.util.noop; - var region = this.region; + let region = this.region; this.request( { @@ -234,7 +234,7 @@ Subnetwork.prototype.delete = function(callback) { return; } - var operation = region.operation(resp.name); + let operation = region.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/vm.js b/src/vm.js index 41d15898..db5e0562 100644 --- a/src/vm.js +++ b/src/vm.js @@ -16,14 +16,14 @@ 'use strict'; -var common = require('@google-cloud/common'); -var createErrorClass = require('create-error-class'); -var extend = require('extend'); -var format = require('string-format-obj'); -var is = require('is'); -var util = require('util'); +let common = require('@google-cloud/common'); +let createErrorClass = require('create-error-class'); +let extend = require('extend'); +let format = require('string-format-obj'); +let is = require('is'); +let util = require('util'); -var Disk = require('./disk.js'); +let Disk = require('./disk.js'); /** * Custom error type for errors related to detaching a disk. @@ -33,7 +33,7 @@ var Disk = require('./disk.js'); * @param {string} message - Custom error message. * @returns {Error} */ -var DetachDiskError = createErrorClass('DetachDiskError'); +let DetachDiskError = createErrorClass('DetachDiskError'); /** * Custom error type for when `waitFor()` does not return a status in a timely @@ -44,14 +44,14 @@ var DetachDiskError = createErrorClass('DetachDiskError'); * @param {string} message - Custom error message. * @returns {Error} */ -var WaitForTimeoutError = createErrorClass('WaitForTimeoutError'); +let WaitForTimeoutError = createErrorClass('WaitForTimeoutError'); /** * The statuses that a VM can be in. * * @private */ -var VALID_STATUSES = [ +let VALID_STATUSES = [ 'PROVISIONING', 'STAGING', 'RUNNING', @@ -66,7 +66,7 @@ var VALID_STATUSES = [ * * @private */ -var WAIT_FOR_POLLING_INTERVAL_MS = 2000; +let WAIT_FOR_POLLING_INTERVAL_MS = 2000; /** * An Instance object allows you to interact with a Google Compute Engine @@ -108,7 +108,7 @@ function VM(zone, name) { name: this.name, }); - var methods = { + let methods = { /** * Create a virtual machine. * @@ -313,7 +313,7 @@ VM.prototype.attachDisk = function(disk, options, callback) { options = {}; } - var body = extend( + let body = extend( { // Default the deviceName to the name of the disk, like the Console does. deviceName: disk.name, @@ -415,7 +415,7 @@ VM.prototype.delete = function(callback) { * }); */ VM.prototype.detachDisk = function(disk, callback) { - var self = this; + let self = this; if (!(disk instanceof Disk)) { throw new Error('A Disk object must be provided.'); @@ -427,20 +427,20 @@ VM.prototype.detachDisk = function(disk, callback) { return; } - var diskName = common.util.replaceProjectIdToken( + let diskName = common.util.replaceProjectIdToken( disk.formattedName, self.zone.compute.authClient.projectId ); - var deviceName; - var baseUrl = 'https://www.googleapis.com/compute/v1/'; - var disks = metadata.disks || []; + let deviceName; + let baseUrl = 'https://www.googleapis.com/compute/v1/'; + let disks = metadata.disks || []; // Try to find the deviceName by matching the source of the attached disks // to the name of the disk provided by the user. - for (var i = 0; !deviceName && i < disks.length; i++) { - var attachedDisk = disks[i]; - var source = attachedDisk.source.replace(baseUrl, ''); + for (let i = 0; !deviceName && i < disks.length; i++) { + let attachedDisk = disks[i]; + let source = attachedDisk.source.replace(baseUrl, ''); if (source === diskName) { deviceName = attachedDisk.deviceName; @@ -499,14 +499,14 @@ VM.prototype.getSerialPortOutput = function(port, callback) { port = 1; } - var reqOpts = { + let reqOpts = { uri: '/serialPort', qs: { port: port, }, }; - var request = common.ServiceObject.prototype.request; + let request = common.ServiceObject.prototype.request; request.call(this, reqOpts, function(err, resp) { if (err) { @@ -658,8 +658,8 @@ VM.prototype.reset = function(callback) { * }); */ VM.prototype.resize = function(machineType, options, callback) { - var self = this; - var compute = this.zone.parent; + let self = this; + let compute = this.zone.parent; if (is.fn(options)) { callback = options; @@ -668,7 +668,7 @@ VM.prototype.resize = function(machineType, options, callback) { options = options || {}; - var isPartialMachineType = machineType.indexOf('/') === -1; + let isPartialMachineType = machineType.indexOf('/') === -1; if (isPartialMachineType) { machineType = format('zones/{zoneName}/machineTypes/{machineType}', { @@ -752,7 +752,7 @@ VM.prototype.resize = function(machineType, options, callback) { * }); */ VM.prototype.setMetadata = function(metadata, callback) { - var self = this; + let self = this; callback = callback || common.util.noop; @@ -762,12 +762,12 @@ VM.prototype.setMetadata = function(metadata, callback) { return; } - var newMetadata = { + let newMetadata = { fingerprint: currentMetadata.metadata.fingerprint, items: [], }; - for (var prop in metadata) { + for (let prop in metadata) { if (metadata.hasOwnProperty(prop)) { newMetadata.items.push({ key: prop, @@ -832,7 +832,7 @@ VM.prototype.setMetadata = function(metadata, callback) { * }); */ VM.prototype.setTags = function(tags, fingerprint, callback) { - var body = { + let body = { items: tags, fingerprint: fingerprint, }; @@ -995,7 +995,7 @@ VM.prototype.waitFor = function(status, options, callback) { // The timeout should default to five minutes, be less than or equal to 10 // minutes, and be greater than or equal to 0 seconds. - var timeout = 300; + let timeout = 300; if (is.number(options.timeout)) { timeout = Math.min(Math.max(options.timeout, 0), 600); @@ -1028,16 +1028,16 @@ VM.prototype.waitFor = function(status, options, callback) { * @private */ VM.prototype.startPolling_ = function() { - var self = this; + let self = this; if (!this.hasActiveWaiters) { return; } this.getMetadata(function(err, metadata) { - var now = new Date() / 1000; + let now = new Date() / 1000; - var waitersToRemove = self.waiters.filter(function(waiter) { + let waitersToRemove = self.waiters.filter(function(waiter) { if (err) { waiter.callback(err); return true; @@ -1049,7 +1049,7 @@ VM.prototype.startPolling_ = function() { } if (now - waiter.startTime >= waiter.timeout) { - var waitForTimeoutError = new WaitForTimeoutError( + let waitForTimeoutError = new WaitForTimeoutError( [ 'waitFor timed out waiting for VM ' + self.name, 'to be in status: ' + waiter.status, @@ -1090,9 +1090,9 @@ VM.prototype.startPolling_ = function() { * @param {function} callback - The callback function. */ VM.prototype.request = function(reqOpts, callback) { - var zone = this.zone; + let zone = this.zone; - var request = common.ServiceObject.prototype.request; + let request = common.ServiceObject.prototype.request; request.call(this, reqOpts, function(err, resp) { if (err) { @@ -1100,7 +1100,7 @@ VM.prototype.request = function(reqOpts, callback) { return; } - var operation = zone.operation(resp.name); + let operation = zone.operation(resp.name); operation.metadata = resp; callback(null, operation, resp); diff --git a/src/zone.js b/src/zone.js index 3b0b1411..f815c73b 100644 --- a/src/zone.js +++ b/src/zone.js @@ -16,21 +16,21 @@ 'use strict'; -var arrify = require('arrify'); -var async = require('async'); -var common = require('@google-cloud/common'); -var extend = require('extend'); -var format = require('string-format-obj'); -var gceImages = require('gce-images'); -var is = require('is'); -var util = require('util'); - -var Autoscaler = require('./autoscaler.js'); -var Disk = require('./disk.js'); -var InstanceGroup = require('./instance-group.js'); -var MachineType = require('./machine-type.js'); -var Operation = require('./operation.js'); -var VM = require('./vm.js'); +let arrify = require('arrify'); +let async = require('async'); +let common = require('@google-cloud/common'); +let extend = require('extend'); +let format = require('string-format-obj'); +let gceImages = require('gce-images'); +let is = require('is'); +let util = require('util'); + +let Autoscaler = require('./autoscaler.js'); +let Disk = require('./disk.js'); +let InstanceGroup = require('./instance-group.js'); +let MachineType = require('./machine-type.js'); +let Operation = require('./operation.js'); +let VM = require('./vm.js'); /** * A Zone object allows you to interact with a Google Compute Engine zone. @@ -48,7 +48,7 @@ var VM = require('./vm.js'); * const zone = compute.zone('us-central1-a'); */ function Zone(compute, name) { - var methods = { + let methods = { /** * Check if the zone exists. * @@ -247,13 +247,13 @@ Zone.prototype.autoscaler = function(name) { * }); */ Zone.prototype.createAutoscaler = function(name, config, callback) { - var self = this; + let self = this; if (!config.target) { throw new Error('Cannot create an autoscaler without a target.'); } - var json = extend(true, {}, config, { + let json = extend(true, {}, config, { name: name, autoscalingPolicy: {}, }); @@ -310,9 +310,9 @@ Zone.prototype.createAutoscaler = function(name, config, callback) { return; } - var autoscaler = self.autoscaler(name); + let autoscaler = self.autoscaler(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, autoscaler, operation, resp); @@ -379,10 +379,10 @@ Zone.prototype.createAutoscaler = function(name, config, callback) { * }); */ Zone.prototype.createDisk = function(name, config, callback) { - var self = this; + let self = this; - var query = {}; - var body = extend({}, config, { + let query = {}; + let body = extend({}, config, { name: name, }); @@ -419,9 +419,9 @@ Zone.prototype.createDisk = function(name, config, callback) { return; } - var disk = self.disk(name); + let disk = self.disk(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, disk, operation, resp); @@ -472,14 +472,14 @@ Zone.prototype.createDisk = function(name, config, callback) { * }); */ Zone.prototype.createInstanceGroup = function(name, options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; options = {}; } - var body = extend({}, options, { + let body = extend({}, options, { name: name, }); @@ -500,9 +500,9 @@ Zone.prototype.createInstanceGroup = function(name, options, callback) { return; } - var instanceGroup = self.instanceGroup(name); + let instanceGroup = self.instanceGroup(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, instanceGroup, operation, resp); @@ -617,9 +617,9 @@ Zone.prototype.createInstanceGroup = function(name, options, callback) { * }); */ Zone.prototype.createVM = function(name, config, callback) { - var self = this; + let self = this; - var body = extend( + let body = extend( { name: name, machineType: 'n1-standard-1', @@ -650,7 +650,7 @@ Zone.prototype.createVM = function(name, config, callback) { // We will add tags to the created instance (http-server and/or // https-server), and create the appropriate firewall rules to allow // connections on the necessary ports to these tags. - var createFirewallMethods = []; + let createFirewallMethods = []; body.networkInterfaces[0].accessConfigs = [ { @@ -729,9 +729,9 @@ Zone.prototype.createVM = function(name, config, callback) { return; } - var vm = self.vm(name); + let vm = self.vm(name); - var operation = self.operation(resp.name); + let operation = self.operation(resp.name); operation.metadata = resp; callback(null, vm, operation, resp); @@ -817,7 +817,7 @@ Zone.prototype.disk = function(name) { * }); */ Zone.prototype.getAutoscalers = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -837,7 +837,7 @@ Zone.prototype.getAutoscalers = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -845,8 +845,8 @@ Zone.prototype.getAutoscalers = function(options, callback) { }); } - var autoscalers = arrify(resp.items).map(function(autoscaler) { - var autoscalerInstance = self.autoscaler(autoscaler.name); + let autoscalers = arrify(resp.items).map(function(autoscaler) { + let autoscalerInstance = self.autoscaler(autoscaler.name); autoscalerInstance.metadata = autoscaler; return autoscalerInstance; @@ -949,7 +949,7 @@ Zone.prototype.getAutoscalersStream = common.paginator.streamify( * }); */ Zone.prototype.getDisks = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -969,7 +969,7 @@ Zone.prototype.getDisks = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -977,8 +977,8 @@ Zone.prototype.getDisks = function(options, callback) { }); } - var disks = (resp.items || []).map(function(disk) { - var diskInstance = self.disk(disk.name); + let disks = (resp.items || []).map(function(disk) { + let diskInstance = self.disk(disk.name); diskInstance.metadata = disk; return diskInstance; }); @@ -1080,7 +1080,7 @@ Zone.prototype.getDisksStream = common.paginator.streamify('getDisks'); * }); */ Zone.prototype.getInstanceGroups = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1100,7 +1100,7 @@ Zone.prototype.getInstanceGroups = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1108,8 +1108,8 @@ Zone.prototype.getInstanceGroups = function(options, callback) { }); } - var instanceGroups = (resp.items || []).map(function(instanceGroup) { - var instanceGroupInstance = self.instanceGroup(instanceGroup.name); + let instanceGroups = (resp.items || []).map(function(instanceGroup) { + let instanceGroupInstance = self.instanceGroup(instanceGroup.name); instanceGroupInstance.metadata = instanceGroup; return instanceGroupInstance; }); @@ -1312,7 +1312,7 @@ Zone.prototype.getMachineTypesStream = common.paginator.streamify( * }); */ Zone.prototype.getOperations = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1332,7 +1332,7 @@ Zone.prototype.getOperations = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1340,8 +1340,8 @@ Zone.prototype.getOperations = function(options, callback) { }); } - var operations = (resp.items || []).map(function(operation) { - var operationInstance = self.operation(operation.name); + let operations = (resp.items || []).map(function(operation) { + let operationInstance = self.operation(operation.name); operationInstance.metadata = operation; return operationInstance; }); @@ -1441,7 +1441,7 @@ Zone.prototype.getOperationsStream = common.paginator.streamify( * }); */ Zone.prototype.getVMs = function(options, callback) { - var self = this; + let self = this; if (is.fn(options)) { callback = options; @@ -1461,7 +1461,7 @@ Zone.prototype.getVMs = function(options, callback) { return; } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, options, { @@ -1469,8 +1469,8 @@ Zone.prototype.getVMs = function(options, callback) { }); } - var vms = (resp.items || []).map(function(instance) { - var vmInstance = self.vm(instance.name); + let vms = (resp.items || []).map(function(instance) { + let vmInstance = self.vm(instance.name); vmInstance.metadata = instance; return vmInstance; }); diff --git a/system-test/compute.js b/system-test/compute.js index 82878741..6ae86b22 100644 --- a/system-test/compute.js +++ b/system-test/compute.js @@ -16,14 +16,14 @@ 'use strict'; -var assert = require('assert'); -var async = require('async'); -var concat = require('concat-stream'); -var is = require('is'); -var prop = require('propprop'); -var uuid = require('uuid'); +let assert = require('assert'); +let async = require('async'); +let concat = require('concat-stream'); +let is = require('is'); +let prop = require('propprop'); +let uuid = require('uuid'); -var Compute = require('../'); +let Compute = require('../'); describe('Compute', function() { // Since the Compute Engine API is rather large and involves long-running @@ -40,20 +40,20 @@ describe('Compute', function() { // deleted. This will also pick up any previously-created objects that were // unable to be removed if a prior test run had unexpectedly quit. - var TESTS_PREFIX = 'gcloud-tests-'; - var REGION_NAME = 'us-central1'; - var ZONE_NAME = 'us-central1-a'; + let TESTS_PREFIX = 'gcloud-tests-'; + let REGION_NAME = 'us-central1'; + let ZONE_NAME = 'us-central1-a'; - var compute = new Compute(); - var region = compute.region(REGION_NAME); - var zone = compute.zone(ZONE_NAME); + let compute = new Compute(); + let region = compute.region(REGION_NAME); + let zone = compute.zone(ZONE_NAME); before(deleteAllTestObjects); after(deleteAllTestObjects); describe('addresses', function() { - var ADDRESS_NAME = generateName('address'); - var address = region.address(ADDRESS_NAME); + let ADDRESS_NAME = generateName('address'); + let address = region.address(ADDRESS_NAME); before(create(address)); @@ -74,7 +74,7 @@ describe('Compute', function() { }); it('should get a list of addresses in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getAddressesStream() @@ -94,14 +94,14 @@ describe('Compute', function() { }); describe('autoscalers', function() { - var AUTOSCALER_NAME = generateName('autoscaler'); - var autoscaler = zone.autoscaler(AUTOSCALER_NAME); + let AUTOSCALER_NAME = generateName('autoscaler'); + let autoscaler = zone.autoscaler(AUTOSCALER_NAME); - var NETWORK_NAME = generateName('network'); - var network = compute.network(NETWORK_NAME); + let NETWORK_NAME = generateName('network'); + let network = compute.network(NETWORK_NAME); - var INSTANCE_TEMPLATE_NAME = generateName('instance-template'); - var INSTANCE_GROUP_MANAGER_NAME = generateName('instance-group-manager'); + let INSTANCE_TEMPLATE_NAME = generateName('instance-template'); + let INSTANCE_GROUP_MANAGER_NAME = generateName('instance-group-manager'); before(function(done) { async.series( @@ -175,7 +175,7 @@ describe('Compute', function() { }); it('should get a list of autoscalers in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getAutoscalersStream() @@ -190,7 +190,7 @@ describe('Compute', function() { }); it('should set & get metadata', function(done) { - var description = 'description'; + let description = 'description'; autoscaler.setMetadata( { @@ -210,8 +210,8 @@ describe('Compute', function() { }); describe('disks', function() { - var DISK_NAME = generateName('disk'); - var disk = zone.disk(DISK_NAME); + let DISK_NAME = generateName('disk'); + let disk = zone.disk(DISK_NAME); before(create(disk, {os: 'ubuntu'})); @@ -232,7 +232,7 @@ describe('Compute', function() { }); it('should get a list of disks in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getDisksStream() @@ -263,20 +263,20 @@ describe('Compute', function() { }); it('should run operation as a promise', function() { - var snapshot = disk.snapshot(generateName('snapshot')); + let snapshot = disk.snapshot(generateName('snapshot')); return snapshot.create().then(function(response) { - var operation = response[1]; + let operation = response[1]; return operation.promise(); }); }); }); describe('firewalls', function() { - var FIREWALL_NAME = generateName('firewall'); - var firewall = compute.firewall(FIREWALL_NAME); + let FIREWALL_NAME = generateName('firewall'); + let firewall = compute.firewall(FIREWALL_NAME); - var CONFIG = { + let CONFIG = { protocols: { tcp: [3000], icmp: true, // This should open all ports on this protocol @@ -286,7 +286,7 @@ describe('Compute', function() { ranges: ['0.0.0.0/0'], }; - var expectedMetadata = { + let expectedMetadata = { allowed: [ { IPProtocol: 'tcp', @@ -323,7 +323,7 @@ describe('Compute', function() { }); it('should get a list of firewalls in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getFirewallsStream() @@ -339,10 +339,10 @@ describe('Compute', function() { }); describe('health checks', function() { - var HEALTH_CHECK_NAME = generateName('health-check'); - var healthCheck = compute.healthCheck(HEALTH_CHECK_NAME); + let HEALTH_CHECK_NAME = generateName('health-check'); + let healthCheck = compute.healthCheck(HEALTH_CHECK_NAME); - var OPTIONS = { + let OPTIONS = { description: 'A health check.', interval: 50, timeout: 25, @@ -363,7 +363,7 @@ describe('Compute', function() { }); it('should set metadata', function(done) { - var description = 'The best description. Possibly ever.'; + let description = 'The best description. Possibly ever.'; healthCheck.setMetadata( { @@ -398,7 +398,7 @@ describe('Compute', function() { }); it('should get a list of health checks in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getHealthChecksStream() @@ -414,12 +414,12 @@ describe('Compute', function() { }); describe('health checks (https)', function() { - var HEALTH_CHECK_NAME = generateName('health-check'); - var healthCheck = compute.healthCheck(HEALTH_CHECK_NAME, { + let HEALTH_CHECK_NAME = generateName('health-check'); + let healthCheck = compute.healthCheck(HEALTH_CHECK_NAME, { https: true, }); - var OPTIONS = { + let OPTIONS = { description: 'A health check.', interval: 50, timeout: 25, @@ -440,7 +440,7 @@ describe('Compute', function() { }); it('should set metadata', function(done) { - var description = 'The best description. Possibly ever.'; + let description = 'The best description. Possibly ever.'; healthCheck.setMetadata( { @@ -475,7 +475,7 @@ describe('Compute', function() { }); it('should get a list of health checks in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getHealthChecksStream({https: true}) @@ -491,8 +491,8 @@ describe('Compute', function() { }); describe('images', function() { - var DISK = zone.disk(generateName('disk')); - var IMAGE = compute.image(generateName('image')); + let DISK = zone.disk(generateName('disk')); + let IMAGE = compute.image(generateName('image')); before(create(DISK, {os: 'ubuntu'})); before(create(IMAGE, DISK)); @@ -514,7 +514,7 @@ describe('Compute', function() { }); it('should list images in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getImagesStream() @@ -530,10 +530,10 @@ describe('Compute', function() { }); describe('instance groups', function() { - var INSTANCE_GROUP_NAME = generateName('instance-group'); - var instanceGroup = zone.instanceGroup(INSTANCE_GROUP_NAME); + let INSTANCE_GROUP_NAME = generateName('instance-group'); + let instanceGroup = zone.instanceGroup(INSTANCE_GROUP_NAME); - var OPTIONS = { + let OPTIONS = { description: 'new instance group', ports: { http: 80, @@ -568,7 +568,7 @@ describe('Compute', function() { }); it('should list project instance groups in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getInstanceGroupsStream() @@ -591,7 +591,7 @@ describe('Compute', function() { }); it('should list zonal instance groups in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; zone .getInstanceGroupsStream() @@ -606,7 +606,7 @@ describe('Compute', function() { }); it('should set named ports', function(done) { - var ports = OPTIONS.ports; + let ports = OPTIONS.ports; instanceGroup.setPorts( ports, @@ -628,7 +628,7 @@ describe('Compute', function() { }); describe('adding and removing VMs', function() { - var vm = zone.vm(generateName('vm')); + let vm = zone.vm(generateName('vm')); before(create(vm, {os: 'ubuntu'})); @@ -640,7 +640,7 @@ describe('Compute', function() { instanceGroup.getVMs(function(err, vms) { assert.ifError(err); - var vmNamesInGroup = vms.map(prop('name')); + let vmNamesInGroup = vms.map(prop('name')); assert(vmNamesInGroup.indexOf(vm.name) > -1); done(); @@ -653,7 +653,7 @@ describe('Compute', function() { .on('error', done) .pipe( concat(function(vms) { - var vmNamesInGroup = vms.map(prop('name')); + let vmNamesInGroup = vms.map(prop('name')); assert(vmNamesInGroup.indexOf(vm.name) > -1); done(); @@ -677,7 +677,7 @@ describe('Compute', function() { }); it('should get a list of machine types in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getMachineTypesStream() @@ -715,7 +715,7 @@ describe('Compute', function() { }); it('should get a list of machine types in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; zone .getMachineTypesStream() @@ -744,10 +744,10 @@ describe('Compute', function() { }); describe('networks', function() { - var NETWORK_NAME = generateName('network'); - var network = compute.network(NETWORK_NAME); + let NETWORK_NAME = generateName('network'); + let network = compute.network(NETWORK_NAME); - var CONFIG = { + let CONFIG = { range: '10.240.0.0/16', }; @@ -770,7 +770,7 @@ describe('Compute', function() { }); it('should get a list of networks in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getNetworksStream() @@ -795,7 +795,7 @@ describe('Compute', function() { }); it('should get a list of operations in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getOperationsStream() @@ -811,7 +811,7 @@ describe('Compute', function() { }); describe('project', function() { - var project; + let project; beforeEach(function() { project = compute.project(); @@ -844,7 +844,7 @@ describe('Compute', function() { }); it('should get a list of regions in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getRegionsStream() @@ -867,7 +867,7 @@ describe('Compute', function() { }); it('should get a list of addresses in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; region .getOperationsStream() @@ -890,7 +890,7 @@ describe('Compute', function() { }); it('should get a list of operations in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; region .getOperationsStream() @@ -906,19 +906,19 @@ describe('Compute', function() { }); describe('rules', function() { - var RULE_NAME = generateName('rule'); - var rule = compute.rule(RULE_NAME); + let RULE_NAME = generateName('rule'); + let rule = compute.rule(RULE_NAME); - var service = compute.service(generateName('service')); + let service = compute.service(generateName('service')); - var INSTANCE_GROUP_NAME = generateName('instance-group'); - var HEALTH_CHECK_NAME = generateName('health-check'); + let INSTANCE_GROUP_NAME = generateName('instance-group'); + let HEALTH_CHECK_NAME = generateName('health-check'); // To create a rule, we need to also create a TargetHttpProxy and UrlMap. // Until they are officially supported by google-cloud-node, we make manual // requests to create and delete them. - var TARGET_PROXY_NAME = generateName('target-proxy'); - var URL_MAP_NAME = generateName('url-map'); + let TARGET_PROXY_NAME = generateName('target-proxy'); + let URL_MAP_NAME = generateName('url-map'); before(function(done) { async.series( @@ -971,7 +971,7 @@ describe('Compute', function() { }); it('should have created the right rule', function(done) { - var target = [ + let target = [ 'https://www.googleapis.com/compute/v1/global/targetHttpProxies/', TARGET_PROXY_NAME, ].join(''); @@ -992,7 +992,7 @@ describe('Compute', function() { }); it('should set a new target', function(done) { - var target = [ + let target = [ 'https://www.googleapis.com/compute/v1/projects/' + compute.projectId, '/global/targetHttpProxies/' + TARGET_PROXY_NAME, ].join(''); @@ -1019,13 +1019,13 @@ describe('Compute', function() { }); describe('rules (regional)', function() { - var RULE_NAME = generateName('rule'); - var rule = region.rule(RULE_NAME); + let RULE_NAME = generateName('rule'); + let rule = region.rule(RULE_NAME); - var TARGET_INSTANCE_NAME = generateName('target-instance'); + let TARGET_INSTANCE_NAME = generateName('target-instance'); - var VM_NAME = generateName('vm'); - var vm = zone.vm(VM_NAME); + let VM_NAME = generateName('vm'); + let vm = zone.vm(VM_NAME); before(function(done) { async.series( @@ -1059,7 +1059,7 @@ describe('Compute', function() { }); it('should have created the right rule', function(done) { - var target = [ + let target = [ 'https://www.googleapis.com/compute/v1/projects/' + compute.projectId, '/zones/' + zone.name + '/targetInstances/' + TARGET_INSTANCE_NAME, ].join(''); @@ -1081,10 +1081,10 @@ describe('Compute', function() { }); describe('services', function() { - var service = compute.service(generateName('service')); + let service = compute.service(generateName('service')); - var INSTANCE_GROUP_NAME = generateName('instance-group'); - var HEALTH_CHECK_NAME = generateName('health-check'); + let INSTANCE_GROUP_NAME = generateName('instance-group'); + let HEALTH_CHECK_NAME = generateName('health-check'); before(function(done) { createService(service.name, INSTANCE_GROUP_NAME, HEALTH_CHECK_NAME, done); @@ -1099,7 +1099,7 @@ describe('Compute', function() { }); it('should get a list of services in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getServicesStream() @@ -1128,7 +1128,7 @@ describe('Compute', function() { }); it('should set metadata', function(done) { - var description = 'The best description. Possibly ever.'; + let description = 'The best description. Possibly ever.'; service.setMetadata( { @@ -1165,7 +1165,7 @@ describe('Compute', function() { }); it('should get a list of snapshots in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getSnapshotsStream() @@ -1181,17 +1181,17 @@ describe('Compute', function() { }); describe('subnetworks', function() { - var NETWORK_NAME = generateName('network'); - var network = compute.network(NETWORK_NAME); + let NETWORK_NAME = generateName('network'); + let network = compute.network(NETWORK_NAME); - var SUBNETWORK_NAME = generateName('subnetwork'); - var subnetwork = region.subnetwork(SUBNETWORK_NAME); + let SUBNETWORK_NAME = generateName('subnetwork'); + let subnetwork = region.subnetwork(SUBNETWORK_NAME); - var NETWORK_CONFIG = { + let NETWORK_CONFIG = { autoCreateSubnetworks: false, }; - var SUBNETWORK_CONFIG = { + let SUBNETWORK_CONFIG = { network: 'global/networks/' + NETWORK_NAME, range: '10.0.1.0/24', }; @@ -1223,7 +1223,7 @@ describe('Compute', function() { }); it('should get a list of subnetworks in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getSubnetworksStream() @@ -1246,7 +1246,7 @@ describe('Compute', function() { }); it('should get a list of regional subnetworks in stream', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; region .getSubnetworksStream() @@ -1266,8 +1266,8 @@ describe('Compute', function() { }); describe('vms', function() { - var VM_NAME = generateName('vm'); - var vm = zone.vm(VM_NAME); + let VM_NAME = generateName('vm'); + let vm = zone.vm(VM_NAME); before(create(vm, {os: 'ubuntu', http: true})); @@ -1288,7 +1288,7 @@ describe('Compute', function() { }); it('should get a list of vms in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getVMsStream() @@ -1307,12 +1307,12 @@ describe('Compute', function() { }); it('should attach and detach a disk', function(done) { - var disk = zone.disk(generateName('disk')); + let disk = zone.disk(generateName('disk')); async.series([createDisk, attachDisk, detachDisk], done); function createDisk(callback) { - var config = { + let config = { os: 'ubuntu', }; @@ -1333,7 +1333,7 @@ describe('Compute', function() { }); it('should set tags', function(done) { - var newTagName = 'new-tag'; + let newTagName = 'new-tag'; vm.getTags(function(err, tags, fingerprint) { assert.ifError(err); @@ -1361,7 +1361,7 @@ describe('Compute', function() { }); it('should resize the machine', function(done) { - var machineType = 'n1-standard-2'; + let machineType = 'n1-standard-2'; vm.resize(machineType, function(err) { assert.ifError(err); @@ -1369,7 +1369,7 @@ describe('Compute', function() { vm.getMetadata(function(err, metadata) { assert.ifError(err); - var expectedMachineType = [ + let expectedMachineType = [ 'https://www.googleapis.com/compute/v1', 'zones', zone.id, @@ -1391,10 +1391,10 @@ describe('Compute', function() { }); it('should set metadata', function(done) { - var key = 'newKey'; - var value = 'newValue'; + let key = 'newKey'; + let value = 'newValue'; - var newMetadata = {}; + let newMetadata = {}; newMetadata[key] = value; vm.setMetadata( @@ -1448,7 +1448,7 @@ describe('Compute', function() { }); it('should get a list of zones in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; compute .getZonesStream() @@ -1471,7 +1471,7 @@ describe('Compute', function() { }); it('should get a list of disks in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; zone .getDisksStream() @@ -1494,7 +1494,7 @@ describe('Compute', function() { }); it('should get a list of operations in stream mode', function(done) { - var resultsMatched = 0; + let resultsMatched = 0; zone .getOperationsStream() @@ -1649,11 +1649,11 @@ describe('Compute', function() { } function createService(name, instanceGroupName, healthCheckName, callback) { - var service = compute.service(name); - var group = zone.instanceGroup(instanceGroupName); - var healthCheck = compute.healthCheck(healthCheckName); - var groupUrl; - var healthCheckUrl; + let service = compute.service(name); + let group = zone.instanceGroup(instanceGroupName); + let healthCheck = compute.healthCheck(healthCheckName); + let groupUrl; + let healthCheckUrl; async.series( [ @@ -1764,7 +1764,7 @@ describe('Compute', function() { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); @@ -1784,7 +1784,7 @@ describe('Compute', function() { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); @@ -1833,7 +1833,7 @@ describe('Compute', function() { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); @@ -1853,7 +1853,7 @@ describe('Compute', function() { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); @@ -1905,7 +1905,7 @@ describe('Compute', function() { return; } - var operation = zone.operation(resp.name); + let operation = zone.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); @@ -1925,7 +1925,7 @@ describe('Compute', function() { return; } - var operation = zone.operation(resp.name); + let operation = zone.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); @@ -1957,7 +1957,7 @@ describe('Compute', function() { return; } - var names = resp.items.map(prop('name')); + let names = resp.items.map(prop('name')); async.each(names, deleteInstanceTemplate, callback); }); } @@ -2005,7 +2005,7 @@ describe('Compute', function() { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); @@ -2025,7 +2025,7 @@ describe('Compute', function() { return; } - var operation = compute.operation(resp.name); + let operation = compute.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); @@ -2057,7 +2057,7 @@ describe('Compute', function() { return; } - var names = resp.items.map(prop('name')); + let names = resp.items.map(prop('name')); async.each(names, deleteInstanceGroupManager, callback); }); } @@ -2080,7 +2080,7 @@ describe('Compute', function() { return; } - var operation = zone.operation(resp.name); + let operation = zone.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); @@ -2100,7 +2100,7 @@ describe('Compute', function() { return; } - var operation = zone.operation(resp.name); + let operation = zone.operation(resp.name); operation.on('error', callback).on('complete', function() { callback(); }); diff --git a/test/address.js b/test/address.js index 0dfe6f1c..f0c6f8b7 100644 --- a/test/address.js +++ b/test/address.js @@ -16,15 +16,15 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let assert = require('assert'); +let extend = require('extend'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'Address') { promisified = true; @@ -40,11 +40,11 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Address', function() { - var Address; - var address; + let Address; + let address; - var ADDRESS_NAME = 'us-central1'; - var REGION = { + let ADDRESS_NAME = 'us-central1'; + let REGION = { createAddress: util.noop, }; @@ -84,10 +84,10 @@ describe('Address', function() { }, }); - var address = new Address(regionInstance, ADDRESS_NAME); + let address = new Address(regionInstance, ADDRESS_NAME); assert(address instanceof ServiceObject); - var calledWith = address.calledWith_[0]; + let calledWith = address.calledWith_[0]; assert.strictEqual(calledWith.parent, regionInstance); assert.strictEqual(calledWith.baseUrl, '/addresses'); @@ -113,8 +113,8 @@ describe('Address', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { address.request = function(reqOpts, callback) { @@ -139,7 +139,7 @@ describe('Address', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -150,7 +150,7 @@ describe('Address', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; address.region.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/autoscaler.js b/test/autoscaler.js index 8d680106..3c7aee58 100644 --- a/test/autoscaler.js +++ b/test/autoscaler.js @@ -16,15 +16,15 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let assert = require('assert'); +let extend = require('extend'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'Autoscaler') { promisified = true; @@ -40,13 +40,13 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Autoscaler', function() { - var Autoscaler; - var autoscaler; + let Autoscaler; + let autoscaler; - var AUTOSCALER_NAME = 'autoscaler-name'; + let AUTOSCALER_NAME = 'autoscaler-name'; - var COMPUTE = {projectId: 'project-id'}; - var ZONE = { + let COMPUTE = {projectId: 'project-id'}; + let ZONE = { compute: COMPUTE, name: 'us-central1-a', createAutoscaler: util.noop, @@ -79,7 +79,7 @@ describe('Autoscaler', function() { }); it('should inherit from ServiceObject', function() { - var createMethod = util.noop; + let createMethod = util.noop; var zoneInstance = extend({}, ZONE, { createAutoscaler: { @@ -90,10 +90,10 @@ describe('Autoscaler', function() { }, }); - var autoscaler = new Autoscaler(zoneInstance, AUTOSCALER_NAME); + let autoscaler = new Autoscaler(zoneInstance, AUTOSCALER_NAME); assert(autoscaler instanceof ServiceObject); - var calledWith = autoscaler.calledWith_[0]; + let calledWith = autoscaler.calledWith_[0]; assert.strictEqual(calledWith.parent, zoneInstance); assert.strictEqual(calledWith.baseUrl, '/autoscalers'); @@ -119,8 +119,8 @@ describe('Autoscaler', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -145,7 +145,7 @@ describe('Autoscaler', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -156,7 +156,7 @@ describe('Autoscaler', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; autoscaler.zone.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -182,7 +182,7 @@ describe('Autoscaler', function() { describe('setMetadata', function() { it('should make the correct API request', function(done) { - var metadata = {}; + let metadata = {}; autoscaler.zone.request = function(reqOpts) { assert.strictEqual(reqOpts.method, 'PATCH'); @@ -200,8 +200,8 @@ describe('Autoscaler', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { autoscaler.zone.request = function(reqOpts, callback) { @@ -220,7 +220,7 @@ describe('Autoscaler', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -231,8 +231,8 @@ describe('Autoscaler', function() { }); it('should execute callback with operation & response', function(done) { - var operation = {}; - var metadata = {a: 'b'}; + let operation = {}; + let metadata = {a: 'b'}; autoscaler.zone.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/disk.js b/test/disk.js index 450b20b1..aa33a346 100644 --- a/test/disk.js +++ b/test/disk.js @@ -16,16 +16,16 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var format = require('string-format-obj'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let assert = require('assert'); +let extend = require('extend'); +let format = require('string-format-obj'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class, options) { if (Class.name !== 'Disk') { return; @@ -48,21 +48,21 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Disk', function() { - var Disk; - var disk; + let Disk; + let disk; - var COMPUTE = { + let COMPUTE = { projectId: 'project-id', }; - var ZONE = { + let ZONE = { compute: COMPUTE, name: 'us-central1-a', createDisk: util.noop, }; - var DISK_NAME = 'disk-name'; - var DISK_FULL_NAME = format('projects/{pId}/zones/{zName}/disks/{dName}', { + let DISK_NAME = 'disk-name'; + let DISK_FULL_NAME = format('projects/{pId}/zones/{zName}/disks/{dName}', { pId: COMPUTE.projectId, zName: ZONE.name, dName: DISK_NAME, @@ -96,8 +96,8 @@ describe('Disk', function() { }); it('should format the disk name', function() { - var formatName_ = Disk.formatName_; - var formattedName = 'projects/a/zones/b/disks/c'; + let formatName_ = Disk.formatName_; + let formattedName = 'projects/a/zones/b/disks/c'; Disk.formatName_ = function(zone, name) { Disk.formatName_ = formatName_; @@ -108,7 +108,7 @@ describe('Disk', function() { return formattedName; }; - var disk = new Disk(ZONE, DISK_NAME); + let disk = new Disk(ZONE, DISK_NAME); assert(disk.formattedName, formattedName); }); @@ -122,10 +122,10 @@ describe('Disk', function() { }, }); - var disk = new Disk(zoneInstance, DISK_NAME); + let disk = new Disk(zoneInstance, DISK_NAME); assert(disk instanceof ServiceObject); - var calledWith = disk.calledWith_[0]; + let calledWith = disk.calledWith_[0]; assert.strictEqual(calledWith.parent, zoneInstance); assert.strictEqual(calledWith.baseUrl, '/disks'); @@ -141,7 +141,7 @@ describe('Disk', function() { describe('formatName_', function() { it('should format the name', function() { - var formattedName_ = Disk.formatName_(ZONE, DISK_NAME); + let formattedName_ = Disk.formatName_(ZONE, DISK_NAME); assert.strictEqual(formattedName_, DISK_FULL_NAME); }); }); @@ -159,8 +159,8 @@ describe('Disk', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { disk.request = function(reqOpts, callback) { @@ -186,7 +186,7 @@ describe('Disk', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -197,8 +197,8 @@ describe('Disk', function() { }); it('should execute callback with Snapshot & Operation', function(done) { - var snapshot = {}; - var operation = {}; + let snapshot = {}; + let operation = {}; disk.snapshot = function(name) { assert.strictEqual(name, 'test'); @@ -241,8 +241,8 @@ describe('Disk', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -267,7 +267,7 @@ describe('Disk', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -278,7 +278,7 @@ describe('Disk', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; disk.zone.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -303,10 +303,10 @@ describe('Disk', function() { }); describe('snapshot', function() { - var NAME = 'snapshot-name'; + let NAME = 'snapshot-name'; it('should return a Snapshot object', function() { - var snapshot = disk.snapshot(NAME); + let snapshot = disk.snapshot(NAME); assert(snapshot instanceof FakeSnapshot); assert.strictEqual(snapshot.calledWith_[0], disk); assert.strictEqual(snapshot.calledWith_[1], NAME); diff --git a/test/firewall.js b/test/firewall.js index e97b6aa4..49c989ed 100644 --- a/test/firewall.js +++ b/test/firewall.js @@ -16,15 +16,15 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let assert = require('assert'); +let extend = require('extend'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'Firewall') { promisified = true; @@ -40,15 +40,15 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Firewall', function() { - var Firewall; - var firewall; + let Firewall; + let firewall; - var COMPUTE = { + let COMPUTE = { projectId: 'project-id', createFirewall: util.noop, }; - var FIREWALL_NAME = 'tcp-3000'; - var FIREWALL_NETWORK = 'global/networks/default'; + let FIREWALL_NAME = 'tcp-3000'; + let FIREWALL_NETWORK = 'global/networks/default'; before(function() { Firewall = proxyquire('../src/firewall.js', { @@ -89,11 +89,11 @@ describe('Firewall', function() { }, }); - var firewall = new Firewall(computeInstance, FIREWALL_NAME); + let firewall = new Firewall(computeInstance, FIREWALL_NAME); assert(firewall instanceof ServiceObject); - var calledWith = firewall.calledWith_[0]; + let calledWith = firewall.calledWith_[0]; assert.strictEqual(calledWith.parent, computeInstance); assert.strictEqual(calledWith.baseUrl, '/global/firewalls'); @@ -118,8 +118,8 @@ describe('Firewall', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -144,7 +144,7 @@ describe('Firewall', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -155,7 +155,7 @@ describe('Firewall', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; firewall.compute.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -181,7 +181,7 @@ describe('Firewall', function() { describe('setMetadata', function() { it('should make the correct API request', function(done) { - var metadata = {}; + let metadata = {}; firewall.request = function(reqOpts) { assert.strictEqual(reqOpts.method, 'PATCH'); @@ -199,8 +199,8 @@ describe('Firewall', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { firewall.request = function(reqOpts, callback) { @@ -219,7 +219,7 @@ describe('Firewall', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -230,8 +230,8 @@ describe('Firewall', function() { }); it('should execute callback with operation & response', function(done) { - var operation = {}; - var metadata = {a: 'b'}; + let operation = {}; + let metadata = {a: 'b'}; firewall.compute.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/health-check.js b/test/health-check.js index ecd774a8..066b2290 100644 --- a/test/health-check.js +++ b/test/health-check.js @@ -16,15 +16,15 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let assert = require('assert'); +let extend = require('extend'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'HealthCheck') { promisified = true; @@ -39,14 +39,14 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('HealthCheck', function() { - var HealthCheck; - var healthCheck; + let HealthCheck; + let healthCheck; - var COMPUTE = { + let COMPUTE = { createHealthCheck: util.noop, }; - var HEALTH_CHECK_NAME = 'health-check-name'; - var OPTIONS = {}; + let HEALTH_CHECK_NAME = 'health-check-name'; + let OPTIONS = {}; before(function() { HealthCheck = proxyquire('../src/health-check.js', { @@ -69,7 +69,7 @@ describe('HealthCheck', function() { it('should inherit from ServiceObject', function() { assert(healthCheck instanceof FakeServiceObject); - var calledWith = healthCheck.calledWith_[0]; + let calledWith = healthCheck.calledWith_[0]; assert.strictEqual(calledWith.parent, COMPUTE); assert.strictEqual(calledWith.id, HEALTH_CHECK_NAME); @@ -87,17 +87,17 @@ describe('HealthCheck', function() { describe('http', function() { it('should set the correct baseUrl', function() { - var calledWith = healthCheck.calledWith_[0]; + let calledWith = healthCheck.calledWith_[0]; assert.strictEqual(calledWith.baseUrl, '/global/httpHealthChecks'); }); it('should not set options.https when created', function(done) { - var createMethod = healthCheck.calledWith_[0].createMethod; + let createMethod = healthCheck.calledWith_[0].createMethod; - var NAME = 'name'; - var OPTIONS = {a: 'b'}; - var originalOptions = extend({}, OPTIONS); + let NAME = 'name'; + let OPTIONS = {a: 'b'}; + let originalOptions = extend({}, OPTIONS); COMPUTE.createHealthCheck = function(name, opts, callback) { assert.strictEqual(name, NAME); @@ -110,7 +110,7 @@ describe('HealthCheck', function() { }); it('should not require a callback when creating', function(done) { - var createMethod = healthCheck.calledWith_[0].createMethod; + let createMethod = healthCheck.calledWith_[0].createMethod; COMPUTE.createHealthCheck = function(name, opts, callback) { assert.deepStrictEqual(opts, {}); @@ -122,7 +122,7 @@ describe('HealthCheck', function() { }); describe('https', function() { - var healthCheck; + let healthCheck; beforeEach(function() { healthCheck = new HealthCheck(COMPUTE, HEALTH_CHECK_NAME, { @@ -131,17 +131,17 @@ describe('HealthCheck', function() { }); it('should set the correct baseUrl', function() { - var calledWith = healthCheck.calledWith_[0]; + let calledWith = healthCheck.calledWith_[0]; assert.strictEqual(calledWith.baseUrl, '/global/httpsHealthChecks'); }); it('should set options.https = true when created', function(done) { - var createMethod = healthCheck.calledWith_[0].createMethod; + let createMethod = healthCheck.calledWith_[0].createMethod; - var NAME = 'name'; - var OPTIONS = {a: 'b'}; - var originalOptions = extend({}, OPTIONS); + let NAME = 'name'; + let OPTIONS = {a: 'b'}; + let originalOptions = extend({}, OPTIONS); COMPUTE.createHealthCheck = function(name, opts, callback) { assert.strictEqual(name, NAME); @@ -154,7 +154,7 @@ describe('HealthCheck', function() { }); it('should not require a callback when creating', function(done) { - var createMethod = healthCheck.calledWith_[0].createMethod; + let createMethod = healthCheck.calledWith_[0].createMethod; COMPUTE.createHealthCheck = function(name, opts, callback) { assert.deepStrictEqual(opts, {https: true}); @@ -177,8 +177,8 @@ describe('HealthCheck', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -203,7 +203,7 @@ describe('HealthCheck', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -214,7 +214,7 @@ describe('HealthCheck', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; healthCheck.compute.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -239,7 +239,7 @@ describe('HealthCheck', function() { }); describe('setMetadata', function() { - var METADATA = {}; + let METADATA = {}; it('should call ServiceObject.setMetadata', function(done) { FakeServiceObject.prototype.setMetadata = function(metadata) { @@ -252,8 +252,8 @@ describe('HealthCheck', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {}; + let error = new Error('Error.'); + let apiResponse = {}; beforeEach(function() { FakeServiceObject.prototype.setMetadata = function(metadata, callback) { @@ -272,7 +272,7 @@ describe('HealthCheck', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -283,8 +283,8 @@ describe('HealthCheck', function() { }); it('should execute callback with operation & response', function(done) { - var operation = {}; - var metadata = {a: 'b'}; + let operation = {}; + let metadata = {a: 'b'}; healthCheck.compute.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/image.js b/test/image.js index 2c494939..3e22aa75 100644 --- a/test/image.js +++ b/test/image.js @@ -16,15 +16,15 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let assert = require('assert'); +let extend = require('extend'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'Image') { promisified = true; @@ -40,15 +40,15 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Image', function() { - var Image; - var image; + let Image; + let image; - var COMPUTE = { + let COMPUTE = { projectId: 'project-id', createImage: util.noop, operation: util.noop, }; - var IMAGE_NAME = 'image-name'; + let IMAGE_NAME = 'image-name'; before(function() { Image = proxyquire('../src/image.js', { @@ -78,10 +78,10 @@ describe('Image', function() { }, }); - var image = new Image(computeInstance, IMAGE_NAME); + let image = new Image(computeInstance, IMAGE_NAME); assert(image instanceof ServiceObject); - var calledWith = image.calledWith_[0]; + let calledWith = image.calledWith_[0]; assert.strictEqual(calledWith.parent, computeInstance); assert.strictEqual(calledWith.baseUrl, '/global/images'); @@ -106,8 +106,8 @@ describe('Image', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -132,7 +132,7 @@ describe('Image', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -143,7 +143,7 @@ describe('Image', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; image.parent.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/index.js b/test/index.js index 55ef2143..599a50b1 100644 --- a/test/index.js +++ b/test/index.js @@ -16,20 +16,20 @@ 'use strict'; -var arrify = require('arrify'); -var assert = require('assert'); -var events = require('events'); -var extend = require('extend'); -var format = require('string-format-obj'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var Service = require('@google-cloud/common').Service; -var util = require('@google-cloud/common').util; - -var slice = Array.prototype.slice; - -var promisified = false; -var fakeUtil = extend({}, util, { +let arrify = require('arrify'); +let assert = require('assert'); +let events = require('events'); +let extend = require('extend'); +let format = require('string-format-obj'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let Service = require('@google-cloud/common').Service; +let util = require('@google-cloud/common').util; + +let slice = Array.prototype.slice; + +let promisified = false; +let fakeUtil = extend({}, util, { makeAuthenticatedRequestFactory: util.noop, promisifyAll: function(Class, options) { if (Class.name !== 'Compute') { @@ -59,9 +59,9 @@ var fakeUtil = extend({}, util, { ]); }, }); -var originalFakeUtil = extend(true, {}, fakeUtil); +let originalFakeUtil = extend(true, {}, fakeUtil); -var fakePaginator = { +let fakePaginator = { extend: function(Class, methods) { if (Class.name !== 'Compute') { return; @@ -160,10 +160,10 @@ function FakeService() { nodeutil.inherits(FakeService, Service); describe('Compute', function() { - var Compute; - var compute; + let Compute; + let compute; - var PROJECT_ID = 'project-id'; + let PROJECT_ID = 'project-id'; before(function() { // Node v4 on Circle times out. @@ -198,13 +198,13 @@ describe('Compute', function() { describe('instantiation', function() { it('should return a new instance of Compute', function() { - var compute = new Compute({projectId: PROJECT_ID}); + let compute = new Compute({projectId: PROJECT_ID}); assert(compute instanceof Compute); }); it('should normalize the arguments', function() { - var normalizeArgumentsCalled = false; - var options = {}; + let normalizeArgumentsCalled = false; + let options = {}; fakeUtil.normalizeArguments = function(context, options_) { normalizeArgumentsCalled = true; @@ -219,9 +219,9 @@ describe('Compute', function() { it('should inherit from Service', function() { assert(compute instanceof Service); - var calledWith = compute.calledWith_[0]; + let calledWith = compute.calledWith_[0]; - var baseUrl = 'https://www.googleapis.com/compute/v1'; + let baseUrl = 'https://www.googleapis.com/compute/v1'; assert.strictEqual(calledWith.baseUrl, baseUrl); assert.deepStrictEqual(calledWith.scopes, [ 'https://www.googleapis.com/auth/compute', @@ -272,7 +272,7 @@ describe('Compute', function() { describe('config.protocols', function() { it('should format protocols', function(done) { - var options = { + let options = { allowed: { IPProtocol: 'http', ports: [8000], @@ -303,7 +303,7 @@ describe('Compute', function() { describe('config.ranges', function() { it('should format ranges to sourceRanges', function(done) { - var options = { + let options = { ranges: '0.0.0.0/0', // non-array to test that it's arrified. }; @@ -319,7 +319,7 @@ describe('Compute', function() { describe('config.tags', function() { it('should format tags to sourceTags', function(done) { - var options = { + let options = { tags: 'tag', // non-array to test that it's arrified. }; @@ -334,7 +334,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var name = 'new-firewall-name'; + let name = 'new-firewall-name'; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.method, 'POST'); @@ -347,8 +347,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -368,7 +368,7 @@ describe('Compute', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -379,9 +379,9 @@ describe('Compute', function() { }); it('should exec cb with Firewall, Operation & apiResp', function(done) { - var name = 'name'; - var firewall = {}; - var operation = {}; + let name = 'name'; + let firewall = {}; + let operation = {}; compute.firewall = function(name_) { assert.strictEqual(name_, name); @@ -414,7 +414,7 @@ describe('Compute', function() { describe('options.interval', function() { it('should set checkIntervalSec', function(done) { - var options = {interval: 50}; + let options = {interval: 50}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.json.checkIntervalSec, options.interval); @@ -428,7 +428,7 @@ describe('Compute', function() { describe('config.timeout', function() { it('should set timeoutSec', function(done) { - var options = {timeout: 50}; + let options = {timeout: 50}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.json.timeoutSec, options.timeout); @@ -442,7 +442,7 @@ describe('Compute', function() { describe('options.https', function() { it('should make the correct API request', function(done) { - var name = 'https-health-check-name'; + let name = 'https-health-check-name'; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.json.https, undefined); @@ -456,9 +456,9 @@ describe('Compute', function() { }); it('should make the correct default API request', function(done) { - var name = 'new-health-check-name'; - var options = {a: 'b'}; - var originalOptions = extend({}, options); + let name = 'new-health-check-name'; + let options = {a: 'b'}; + let originalOptions = extend({}, options); compute.request = function(reqOpts) { assert.strictEqual(reqOpts.method, 'POST'); @@ -472,8 +472,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -493,7 +493,7 @@ describe('Compute', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -504,9 +504,9 @@ describe('Compute', function() { }); it('should exec cb with HealthCheck, Op, & apiResp', function(done) { - var name = 'name'; - var healthCheck = {}; - var operation = {}; + let name = 'name'; + let healthCheck = {}; + let operation = {}; compute.healthCheck = function(name_, options) { assert.strictEqual(name_, name); @@ -530,7 +530,7 @@ describe('Compute', function() { }); it('should create an HTTPS HealthCheck object', function(done) { - var name = 'name'; + let name = 'name'; compute.healthCheck = function(name_, options) { assert.strictEqual(name_, name); @@ -544,9 +544,9 @@ describe('Compute', function() { }); describe('createImage', function() { - var NAME = 'image-name'; + let NAME = 'image-name'; - var DISK = { + let DISK = { name: 'disk-name', zone: { name: 'zone-name', @@ -572,7 +572,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = { + let options = { a: 'b', c: 'd', }; @@ -597,8 +597,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {}; + let error = new Error('Error.'); + let apiResponse = {}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -617,7 +617,7 @@ describe('Compute', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -628,8 +628,8 @@ describe('Compute', function() { }); it('should exec cb with Operation & apiResp', function(done) { - var network = {}; - var operation = {}; + let network = {}; + let operation = {}; compute.network = function(name) { assert.strictEqual(name, NAME); @@ -655,7 +655,7 @@ describe('Compute', function() { describe('createNetwork', function() { describe('config.range', function() { it('should set the IPv4Range', function(done) { - var options = { + let options = { range: '10.240.0.0/16', }; @@ -671,7 +671,7 @@ describe('Compute', function() { describe('config.gateway', function() { it('should set the gatewayIPv4', function(done) { - var options = { + let options = { gateway: '10.1.1.1', }; @@ -686,7 +686,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var name = 'new-network'; + let name = 'new-network'; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.method, 'POST'); @@ -699,8 +699,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -720,8 +720,8 @@ describe('Compute', function() { }); describe('success', function() { - var NAME = 'network-name'; - var apiResponse = { + let NAME = 'network-name'; + let apiResponse = { name: 'op-name', }; @@ -732,8 +732,8 @@ describe('Compute', function() { }); it('should exec cb with Network, Operation & apiResp', function(done) { - var network = {}; - var operation = {}; + let network = {}; + let operation = {}; compute.network = function(name_) { assert.strictEqual(name_, NAME); @@ -758,12 +758,12 @@ describe('Compute', function() { }); describe('createRule', function() { - var NAME = 'new-rule'; + let NAME = 'new-rule'; it('should make the correct API request', function(done) { - var config = {a: 'b'}; - var originalConfig = extend({}, config); - var expectedConfig = extend({}, config, {name: NAME}); + let config = {a: 'b'}; + let originalConfig = extend({}, config); + let expectedConfig = extend({}, config, {name: NAME}); compute.request = function(reqOpts) { assert.strictEqual(reqOpts.method, 'POST'); @@ -777,7 +777,7 @@ describe('Compute', function() { }); describe('config.ip', function() { - var CONFIG = { + let CONFIG = { ip: '0.0.0.0', }; @@ -795,7 +795,7 @@ describe('Compute', function() { }); describe('config.protocol', function() { - var CONFIG = { + let CONFIG = { protocol: 'TCP', }; @@ -813,7 +813,7 @@ describe('Compute', function() { }); describe('config.range', function() { - var CONFIG = { + let CONFIG = { range: '200-300', }; @@ -831,8 +831,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -852,7 +852,7 @@ describe('Compute', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -863,8 +863,8 @@ describe('Compute', function() { }); it('should exec cb with Rule, Operation & apiResp', function(done) { - var rule = {}; - var operation = {}; + let rule = {}; + let operation = {}; compute.rule = function(name) { assert.strictEqual(name, NAME); @@ -889,7 +889,7 @@ describe('Compute', function() { }); describe('createService', function() { - var NAME = 'new-service'; + let NAME = 'new-service'; it('should make the correct API request', function(done) { compute.request = function(reqOpts) { @@ -903,8 +903,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -924,7 +924,7 @@ describe('Compute', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -935,8 +935,8 @@ describe('Compute', function() { }); it('should exec cb with Service, Operation & apiResp', function(done) { - var service = {}; - var operation = {}; + let service = {}; + let operation = {}; compute.service = function(name) { assert.strictEqual(name, NAME); @@ -961,10 +961,10 @@ describe('Compute', function() { }); describe('firewall', function() { - var NAME = 'firewall-name'; + let NAME = 'firewall-name'; it('should return a Firewall object', function() { - var firewall = compute.firewall(NAME); + let firewall = compute.firewall(NAME); assert(firewall instanceof FakeFirewall); assert.strictEqual(firewall.calledWith_[0], compute); assert.strictEqual(firewall.calledWith_[1], NAME); @@ -982,7 +982,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/aggregated/addresses'); @@ -994,8 +994,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1016,11 +1016,11 @@ describe('Compute', function() { }); describe('success', function() { - var REGION_NAME = 'region-1'; - var FULL_REGION_NAME = 'regions/' + REGION_NAME; + let REGION_NAME = 'region-1'; + let FULL_REGION_NAME = 'regions/' + REGION_NAME; - var address = {name: 'address-1'}; - var apiResponse = { + let address = {name: 'address-1'}; + let apiResponse = { items: {}, }; @@ -1035,7 +1035,7 @@ describe('Compute', function() { }); it('should create Address objects from the response', function(done) { - var region = {}; + let region = {}; compute.region = function(name) { assert.strictEqual(name, REGION_NAME); @@ -1052,12 +1052,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -1092,7 +1092,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/aggregated/autoscalers'); @@ -1104,8 +1104,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1126,11 +1126,11 @@ describe('Compute', function() { }); describe('success', function() { - var ZONE_NAME = 'us-central1-a'; - var FULL_ZONE_NAME = 'zones/' + ZONE_NAME; + let ZONE_NAME = 'us-central1-a'; + let FULL_ZONE_NAME = 'zones/' + ZONE_NAME; - var autoscaler = {name: 'autoscaler-1'}; - var apiResponse = { + let autoscaler = {name: 'autoscaler-1'}; + let apiResponse = { items: {}, }; @@ -1149,7 +1149,7 @@ describe('Compute', function() { }); it('should create Autoscaler objects from the response', function(done) { - var zone = {}; + let zone = {}; compute.zone = function(name) { assert.strictEqual(name, ZONE_NAME); @@ -1166,7 +1166,7 @@ describe('Compute', function() { }); it('should not create zone-less Autoscalers', function(done) { - var zone = {}; + let zone = {}; compute.zone = function() { return zone; @@ -1185,14 +1185,14 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); delete apiResponseWithNextPageToken.items; - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -1227,7 +1227,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/aggregated/disks'); @@ -1239,8 +1239,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1261,11 +1261,11 @@ describe('Compute', function() { }); describe('success', function() { - var ZONE_NAME = 'zone-1'; - var FULL_ZONE_NAME = 'zones/' + ZONE_NAME; + let ZONE_NAME = 'zone-1'; + let FULL_ZONE_NAME = 'zones/' + ZONE_NAME; - var disk = {name: 'disk-1'}; - var apiResponse = { + let disk = {name: 'disk-1'}; + let apiResponse = { items: {}, }; @@ -1280,7 +1280,7 @@ describe('Compute', function() { }); it('should create Disk objects from the response', function(done) { - var zone = {}; + let zone = {}; compute.zone = function(name) { assert.strictEqual(name, ZONE_NAME); @@ -1297,12 +1297,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -1337,7 +1337,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/global/firewalls'); @@ -1349,8 +1349,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1371,8 +1371,8 @@ describe('Compute', function() { }); describe('success', function() { - var firewall = {name: 'firewall-1'}; - var apiResponse = { + let firewall = {name: 'firewall-1'}; + let apiResponse = { items: [firewall], }; @@ -1393,12 +1393,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -1433,7 +1433,7 @@ describe('Compute', function() { }); it('should make the correct default API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/global/httpHealthChecks'); @@ -1446,8 +1446,8 @@ describe('Compute', function() { describe('options.https', function() { it('should make the correct API request', function(done) { - var options = {https: true}; - var originalOptions = extend({}, options); + let options = {https: true}; + let originalOptions = extend({}, options); compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/global/httpsHealthChecks'); @@ -1461,8 +1461,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1483,8 +1483,8 @@ describe('Compute', function() { }); describe('success', function() { - var healthCheck = {name: 'health-check-1'}; - var apiResponse = {items: [healthCheck]}; + let healthCheck = {name: 'health-check-1'}; + let apiResponse = {items: [healthCheck]}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1515,12 +1515,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -1555,7 +1555,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/global/images'); @@ -1567,8 +1567,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1589,8 +1589,8 @@ describe('Compute', function() { }); describe('success', function() { - var image = {name: 'image-1'}; - var apiResponse = { + let image = {name: 'image-1'}; + let apiResponse = { items: [image], }; @@ -1611,12 +1611,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -1651,7 +1651,7 @@ describe('Compute', function() { }); it('should make the correct default API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/aggregated/instanceGroups'); @@ -1663,8 +1663,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1685,11 +1685,11 @@ describe('Compute', function() { }); describe('success', function() { - var ZONE_NAME = 'zone-1'; - var FULL_ZONE_NAME = 'zones/' + ZONE_NAME; + let ZONE_NAME = 'zone-1'; + let FULL_ZONE_NAME = 'zones/' + ZONE_NAME; - var instanceGroup = {name: 'instance-group-1'}; - var apiResponse = { + let instanceGroup = {name: 'instance-group-1'}; + let apiResponse = { items: {}, }; @@ -1704,7 +1704,7 @@ describe('Compute', function() { }); it('should create InstanceGroup objects from the resp', function(done) { - var zone = {}; + let zone = {}; compute.zone = function(name) { assert.strictEqual(name, ZONE_NAME); @@ -1721,14 +1721,14 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); delete apiResponseWithNextPageToken.items; - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -1763,7 +1763,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/aggregated/machineTypes'); @@ -1775,8 +1775,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {}; + let error = new Error('Error.'); + let apiResponse = {}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1796,11 +1796,11 @@ describe('Compute', function() { }); describe('success', function() { - var ZONE_NAME = 'zone-1'; - var FULL_ZONE_NAME = 'zones/' + ZONE_NAME; + let ZONE_NAME = 'zone-1'; + let FULL_ZONE_NAME = 'zones/' + ZONE_NAME; - var machineType = {name: 'machineType-1'}; - var apiResponse = { + let machineType = {name: 'machineType-1'}; + let apiResponse = { items: {}, }; @@ -1815,8 +1815,8 @@ describe('Compute', function() { }); it('should create MachineType objects from the response', function(done) { - var zone = {}; - var machineTypeInstance = {}; + let zone = {}; + let machineTypeInstance = {}; compute.zone = function(name) { assert.strictEqual(name, ZONE_NAME); @@ -1839,12 +1839,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -1879,7 +1879,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/global/networks'); @@ -1891,8 +1891,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -1913,8 +1913,8 @@ describe('Compute', function() { }); describe('success', function() { - var network = {name: 'network-1'}; - var apiResponse = { + let network = {name: 'network-1'}; + let apiResponse = { items: [network], }; @@ -1935,12 +1935,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -1975,7 +1975,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/global/operations'); @@ -1987,8 +1987,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -2009,8 +2009,8 @@ describe('Compute', function() { }); describe('success', function() { - var operation = {name: 'op-1'}; - var apiResponse = { + let operation = {name: 'op-1'}; + let apiResponse = { items: [operation], }; @@ -2031,12 +2031,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -2071,7 +2071,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/regions'); @@ -2083,8 +2083,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -2105,8 +2105,8 @@ describe('Compute', function() { }); describe('success', function() { - var region = {name: 'region-1'}; - var apiResponse = { + let region = {name: 'region-1'}; + let apiResponse = { items: [region], }; @@ -2127,12 +2127,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -2167,7 +2167,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/global/forwardingRules'); @@ -2179,8 +2179,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -2201,10 +2201,10 @@ describe('Compute', function() { }); describe('success', function() { - var rule = { + let rule = { name: 'rule-1', }; - var apiResponse = { + let apiResponse = { items: [rule], }; @@ -2228,15 +2228,15 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = { + let query = { a: 'b', c: 'd', }; - var originalQuery = extend({}, query); + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -2271,7 +2271,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/global/backendServices'); @@ -2283,8 +2283,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -2305,10 +2305,10 @@ describe('Compute', function() { }); describe('success', function() { - var service = { + let service = { name: 'service-1', }; - var apiResponse = { + let apiResponse = { items: [service], }; @@ -2329,15 +2329,15 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = { + let query = { a: 'b', c: 'd', }; - var originalQuery = extend({}, query); + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -2372,7 +2372,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/global/snapshots'); @@ -2384,8 +2384,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -2406,8 +2406,8 @@ describe('Compute', function() { }); describe('success', function() { - var snapshot = {name: 'snapshot-1'}; - var apiResponse = { + let snapshot = {name: 'snapshot-1'}; + let apiResponse = { items: [snapshot], }; @@ -2428,12 +2428,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -2468,7 +2468,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/aggregated/subnetworks'); @@ -2480,8 +2480,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -2502,11 +2502,11 @@ describe('Compute', function() { }); describe('success', function() { - var REGION_NAME = 'region-1'; - var FULL_REGION_NAME = 'regions/' + REGION_NAME; + let REGION_NAME = 'region-1'; + let FULL_REGION_NAME = 'regions/' + REGION_NAME; - var subnetwork = {name: 'subnetwork-1'}; - var apiResponse = { + let subnetwork = {name: 'subnetwork-1'}; + let apiResponse = { items: {}, }; @@ -2521,8 +2521,8 @@ describe('Compute', function() { }); it('should create Subnetwork objects from the response', function(done) { - var region = {}; - var fakeSubnetwork = {}; + let region = {}; + let fakeSubnetwork = {}; compute.region = function(name) { assert.strictEqual(name, REGION_NAME); @@ -2548,12 +2548,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -2588,7 +2588,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/aggregated/instances'); @@ -2600,8 +2600,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -2622,11 +2622,11 @@ describe('Compute', function() { }); describe('success', function() { - var ZONE_NAME = 'zone-1'; - var FULL_ZONE_NAME = 'zones/' + ZONE_NAME; + let ZONE_NAME = 'zone-1'; + let FULL_ZONE_NAME = 'zones/' + ZONE_NAME; - var vm = {name: 'vm-1'}; - var apiResponse = { + let vm = {name: 'vm-1'}; + let apiResponse = { items: {}, }; @@ -2641,7 +2641,7 @@ describe('Compute', function() { }); it('should create VM objects from the response', function(done) { - var zone = {}; + let zone = {}; compute.zone = function(name) { assert.strictEqual(name, ZONE_NAME); @@ -2658,12 +2658,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -2698,7 +2698,7 @@ describe('Compute', function() { }); it('should make the correct API request', function(done) { - var options = {}; + let options = {}; compute.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/zones'); @@ -2710,8 +2710,8 @@ describe('Compute', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { compute.request = function(reqOpts, callback) { @@ -2732,8 +2732,8 @@ describe('Compute', function() { }); describe('success', function() { - var zone = {name: 'zone-1'}; - var apiResponse = { + let zone = {name: 'zone-1'}; + let apiResponse = { items: [zone], }; @@ -2754,12 +2754,12 @@ describe('Compute', function() { }); it('should build a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + let query = {a: 'b', c: 'd'}; + let originalQuery = extend({}, query); compute.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -2784,11 +2784,11 @@ describe('Compute', function() { }); describe('healthCheck', function() { - var NAME = 'health-check-name'; - var OPTIONS = {}; + let NAME = 'health-check-name'; + let OPTIONS = {}; it('should return a HealthCheck object', function() { - var healthCheck = compute.healthCheck(NAME, OPTIONS); + let healthCheck = compute.healthCheck(NAME, OPTIONS); assert(healthCheck instanceof FakeHealthCheck); assert.strictEqual(healthCheck.calledWith_[0], compute); assert.strictEqual(healthCheck.calledWith_[1], NAME); @@ -2797,10 +2797,10 @@ describe('Compute', function() { }); describe('image', function() { - var NAME = 'image-name'; + let NAME = 'image-name'; it('should return an Image object', function() { - var image = compute.image(NAME); + let image = compute.image(NAME); assert(image instanceof FakeImage); assert.strictEqual(image.calledWith_[0], compute); assert.strictEqual(image.calledWith_[1], NAME); @@ -2808,10 +2808,10 @@ describe('Compute', function() { }); describe('network', function() { - var NAME = 'network-name'; + let NAME = 'network-name'; it('should return a Network object', function() { - var network = compute.network(NAME); + let network = compute.network(NAME); assert(network instanceof FakeNetwork); assert.strictEqual(network.calledWith_[0], compute); assert.strictEqual(network.calledWith_[1], NAME); @@ -2819,10 +2819,10 @@ describe('Compute', function() { }); describe('operation', function() { - var NAME = 'op-name'; + let NAME = 'op-name'; it('should return an Operation object', function() { - var op = compute.operation(NAME); + let op = compute.operation(NAME); assert(op instanceof FakeOperation); assert.strictEqual(op.calledWith_[0], compute); assert.strictEqual(op.calledWith_[1], NAME); @@ -2831,17 +2831,17 @@ describe('Compute', function() { describe('project', function() { it('should return a Project object', function() { - var project = compute.project(); + let project = compute.project(); assert(project instanceof FakeProject); assert.strictEqual(project.calledWith_[0], compute); }); }); describe('region', function() { - var NAME = 'region-name'; + let NAME = 'region-name'; it('should return a Region object', function() { - var region = compute.region(NAME); + let region = compute.region(NAME); assert(region instanceof FakeRegion); assert.strictEqual(region.calledWith_[0], compute); assert.strictEqual(region.calledWith_[1], NAME); @@ -2849,10 +2849,10 @@ describe('Compute', function() { }); describe('rule', function() { - var NAME = 'rule-name'; + let NAME = 'rule-name'; it('should return a Rule object', function() { - var rule = compute.rule(NAME); + let rule = compute.rule(NAME); assert(rule instanceof FakeRule); assert.strictEqual(rule.calledWith_[0], compute); assert.strictEqual(rule.calledWith_[1], NAME); @@ -2860,10 +2860,10 @@ describe('Compute', function() { }); describe('service', function() { - var NAME = 'service-name'; + let NAME = 'service-name'; it('should return a Service object', function() { - var service = compute.service(NAME); + let service = compute.service(NAME); assert(service instanceof FakeServiceClass); assert.strictEqual(service.calledWith_[0], compute); assert.strictEqual(service.calledWith_[1], NAME); @@ -2871,10 +2871,10 @@ describe('Compute', function() { }); describe('snapshot', function() { - var NAME = 'snapshot-name'; + let NAME = 'snapshot-name'; it('should return a Snapshot object', function() { - var snapshot = compute.snapshot(NAME); + let snapshot = compute.snapshot(NAME); assert(snapshot instanceof FakeSnapshot); assert.strictEqual(snapshot.calledWith_[0], compute); assert.strictEqual(snapshot.calledWith_[1], NAME); @@ -2882,10 +2882,10 @@ describe('Compute', function() { }); describe('zone', function() { - var NAME = 'zone-name'; + let NAME = 'zone-name'; it('should return a Zone object', function() { - var zone = compute.zone(NAME); + let zone = compute.zone(NAME); assert(zone instanceof FakeZone); assert.strictEqual(zone.calledWith_[0], compute); assert.strictEqual(zone.calledWith_[1], NAME); @@ -2893,11 +2893,11 @@ describe('Compute', function() { }); describe('execAfterOperation_', function() { - var OPERATION = new events.EventEmitter(); + let OPERATION = new events.EventEmitter(); it('should execute callback with error & API response', function(done) { - var error = new Error('Error.'); - var apiResponse = {}; + let error = new Error('Error.'); + let apiResponse = {}; function onComplete(err, apiResponse_) { assert.strictEqual(err, error); @@ -2905,14 +2905,14 @@ describe('Compute', function() { done(); } - var execWithOperation = compute.execAfterOperation_(onComplete); + let execWithOperation = compute.execAfterOperation_(onComplete); execWithOperation(error, OPERATION, apiResponse); }); it('should support variable arity', function(done) { - var error = new Error('Error.'); - var apiResponse = {}; + let error = new Error('Error.'); + let apiResponse = {}; function onComplete(err, apiResponse_) { assert.strictEqual(err, error); @@ -2920,13 +2920,13 @@ describe('Compute', function() { done(); } - var execWithOperation = compute.execAfterOperation_(onComplete); + let execWithOperation = compute.execAfterOperation_(onComplete); execWithOperation(error, null, null, OPERATION, apiResponse); }); it('should register callback on operation error', function(done) { - var apiResponse = {}; + let apiResponse = {}; function onComplete() {} @@ -2936,12 +2936,12 @@ describe('Compute', function() { done(); }); - var execWithOperation = compute.execAfterOperation_(onComplete); + let execWithOperation = compute.execAfterOperation_(onComplete); execWithOperation(null, OPERATION, apiResponse); }); it('should execute callback on operation complete', function(done) { - var apiResponse = {}; + let apiResponse = {}; function onComplete(err, apiResponse_) { assert.strictEqual(err, null); @@ -2949,7 +2949,7 @@ describe('Compute', function() { done(); } - var execWithOperation = compute.execAfterOperation_(onComplete); + let execWithOperation = compute.execAfterOperation_(onComplete); execWithOperation(null, OPERATION, {}); OPERATION.emit('complete', apiResponse); diff --git a/test/instance-group.js b/test/instance-group.js index 7e043aa6..28957db2 100644 --- a/test/instance-group.js +++ b/test/instance-group.js @@ -16,17 +16,17 @@ 'use strict'; -var arrify = require('arrify'); -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); +let arrify = require('arrify'); +let assert = require('assert'); +let extend = require('extend'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; -var promisified = false; -var fakeUtil = extend({}, util, { +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'InstanceGroup') { promisified = true; @@ -41,8 +41,8 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); -var extended = false; -var fakePaginator = { +let extended = false; +let fakePaginator = { extend: function(Class, methods) { if (Class.name !== 'InstanceGroup') { return; @@ -59,16 +59,16 @@ var fakePaginator = { }; describe('InstanceGroup', function() { - var InstanceGroup; - var instanceGroup; + let InstanceGroup; + let instanceGroup; - var staticMethods = {}; + let staticMethods = {}; - var ZONE = { + let ZONE = { createInstanceGroup: util.noop, vm: util.noop, }; - var NAME = 'instance-group-name'; + let NAME = 'instance-group-name'; before(function() { InstanceGroup = proxyquire('../src/instance-group.js', { @@ -108,7 +108,7 @@ describe('InstanceGroup', function() { }); it('should inherit from ServiceObject', function(done) { - var instanceGroup; + let instanceGroup; var zoneInstance = extend({}, ZONE, { createInstanceGroup: { @@ -118,7 +118,7 @@ describe('InstanceGroup', function() { setImmediate(function() { assert(instanceGroup instanceof ServiceObject); - var calledWith = instanceGroup.calledWith_[0]; + let calledWith = instanceGroup.calledWith_[0]; assert.strictEqual(calledWith.parent, zoneInstance); assert.strictEqual(calledWith.baseUrl, '/instanceGroups'); @@ -141,7 +141,7 @@ describe('InstanceGroup', function() { }); describe('formatPorts_', function() { - var PORTS = { + let PORTS = { http: 80, https: 443, }; @@ -155,7 +155,7 @@ describe('InstanceGroup', function() { }); describe('add', function() { - var VMS = [{url: 'vm-url'}, {url: 'vm-url-2'}]; + let VMS = [{url: 'vm-url'}, {url: 'vm-url-2'}]; it('should make the correct API request', function(done) { instanceGroup.request = function(reqOpts) { @@ -176,8 +176,8 @@ describe('InstanceGroup', function() { }); describe('error', function() { - var apiResponse = {}; - var error = new Error('Error.'); + let apiResponse = {}; + let error = new Error('Error.'); beforeEach(function() { instanceGroup.request = function(reqOpts, callback) { @@ -196,7 +196,7 @@ describe('InstanceGroup', function() { }); describe('success', function() { - var apiResponse = {name: 'op-name'}; + let apiResponse = {name: 'op-name'}; beforeEach(function() { instanceGroup.request = function(reqOpts, callback) { @@ -205,7 +205,7 @@ describe('InstanceGroup', function() { }); it('should return an Operation and API response', function(done) { - var operation = {}; + let operation = {}; instanceGroup.zone.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -234,8 +234,8 @@ describe('InstanceGroup', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -260,7 +260,7 @@ describe('InstanceGroup', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -271,7 +271,7 @@ describe('InstanceGroup', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; instanceGroup.zone.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -312,7 +312,7 @@ describe('InstanceGroup', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; instanceGroup.request = function(reqOpts) { assert.strictEqual(reqOpts.method, 'POST'); @@ -327,7 +327,7 @@ describe('InstanceGroup', function() { }); describe('options.running', function() { - var OPTIONS = { + let OPTIONS = { running: true, }; @@ -344,8 +344,8 @@ describe('InstanceGroup', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { instanceGroup.request = function(reqOpts, callback) { @@ -365,7 +365,7 @@ describe('InstanceGroup', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{instance: 'vm-name'}], }; @@ -376,11 +376,11 @@ describe('InstanceGroup', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -398,7 +398,7 @@ describe('InstanceGroup', function() { }); it('should execute callback with VMs & API response', function(done) { - var vm = {}; + let vm = {}; instanceGroup.zone.vm = function(name) { assert.strictEqual(name, apiResponse.items[0].instance); @@ -420,7 +420,7 @@ describe('InstanceGroup', function() { }); describe('remove', function() { - var VMS = [{url: 'vm-url'}, {url: 'vm-url-2'}]; + let VMS = [{url: 'vm-url'}, {url: 'vm-url-2'}]; it('should make the correct API request', function(done) { instanceGroup.request = function(reqOpts) { @@ -441,8 +441,8 @@ describe('InstanceGroup', function() { }); describe('error', function() { - var apiResponse = {}; - var error = new Error('Error.'); + let apiResponse = {}; + let error = new Error('Error.'); beforeEach(function() { instanceGroup.request = function(reqOpts, callback) { @@ -461,7 +461,7 @@ describe('InstanceGroup', function() { }); describe('success', function() { - var apiResponse = {name: 'op-name'}; + let apiResponse = {name: 'op-name'}; beforeEach(function() { instanceGroup.request = function(reqOpts, callback) { @@ -470,7 +470,7 @@ describe('InstanceGroup', function() { }); it('should return an Operation and API response', function(done) { - var operation = {}; + let operation = {}; instanceGroup.zone.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -489,13 +489,13 @@ describe('InstanceGroup', function() { }); describe('setPorts', function() { - var PORTS = { + let PORTS = { http: 80, https: 443, }; it('should format the named ports', function(done) { - var expectedNamedPorts = []; + let expectedNamedPorts = []; InstanceGroup.formatPorts_ = function(ports) { assert.strictEqual(ports, PORTS); @@ -513,8 +513,8 @@ describe('InstanceGroup', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { instanceGroup.request = function(reqOpts, callback) { @@ -539,7 +539,7 @@ describe('InstanceGroup', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -550,7 +550,7 @@ describe('InstanceGroup', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; instanceGroup.zone.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/machine-type.js b/test/machine-type.js index c1932144..986c52a3 100644 --- a/test/machine-type.js +++ b/test/machine-type.js @@ -16,10 +16,10 @@ 'use strict'; -var assert = require('assert'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; +let assert = require('assert'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; function FakeServiceObject() { this.calledWith_ = arguments; @@ -29,14 +29,14 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('MachineType', function() { - var MachineType; - var machineType; - var ZONE_NAME = 'zone-1'; - var ZONE = { + let MachineType; + let machineType; + let ZONE_NAME = 'zone-1'; + let ZONE = { name: ZONE_NAME, }; - var MACHINE_TYPE_NAME = 'g1-small'; + let MACHINE_TYPE_NAME = 'g1-small'; before(function() { MachineType = proxyquire('../src/machine-type.js', { @@ -62,7 +62,7 @@ describe('MachineType', function() { it('should inherit from ServiceObject', function() { assert(machineType instanceof ServiceObject); - var calledWith = machineType.calledWith_[0]; + let calledWith = machineType.calledWith_[0]; assert.strictEqual(calledWith.parent, ZONE); assert.strictEqual(calledWith.baseUrl, '/machineTypes'); diff --git a/test/network.js b/test/network.js index 0da515c7..b2e98750 100644 --- a/test/network.js +++ b/test/network.js @@ -16,16 +16,16 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var format = require('string-format-obj'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let assert = require('assert'); +let extend = require('extend'); +let format = require('string-format-obj'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class, options) { if (Class.name !== 'Network') { return; @@ -44,23 +44,23 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Network', function() { - var Network; - var network; + let Network; + let network; /* eslint-disable no-unused-vars */ - var REGION; - var Region; + let REGION; + let Region; - var COMPUTE = { + let COMPUTE = { projectId: 'project-id', createNetwork: util.noop, }; - var NETWORK_NAME = 'network-name'; - var NETWORK_FULL_NAME = format('projects/{pId}/global/networks/{name}', { + let NETWORK_NAME = 'network-name'; + let NETWORK_FULL_NAME = format('projects/{pId}/global/networks/{name}', { pId: COMPUTE.projectId, name: NETWORK_NAME, }); - var REGION_NAME = 'region-name'; + let REGION_NAME = 'region-name'; before(function() { Network = proxyquire('../src/network.js', { @@ -92,8 +92,8 @@ describe('Network', function() { }); it('should format the network name', function() { - var formatName_ = Network.formatName_; - var formattedName = 'projects/a/global/networks/b'; + let formatName_ = Network.formatName_; + let formattedName = 'projects/a/global/networks/b'; Network.formatName_ = function(compute, name) { Network.formatName_ = formatName_; @@ -104,7 +104,7 @@ describe('Network', function() { return formattedName; }; - var network = new Network(COMPUTE, NETWORK_NAME); + let network = new Network(COMPUTE, NETWORK_NAME); assert(network.formattedName, formattedName); }); @@ -118,10 +118,10 @@ describe('Network', function() { }, }); - var network = new Network(computeInstance, NETWORK_NAME); + let network = new Network(computeInstance, NETWORK_NAME); assert(network instanceof ServiceObject); - var calledWith = network.calledWith_[0]; + let calledWith = network.calledWith_[0]; assert.strictEqual(calledWith.parent, computeInstance); assert.strictEqual(calledWith.baseUrl, '/global/networks'); @@ -137,16 +137,16 @@ describe('Network', function() { describe('formatName_', function() { it('should format the name', function() { - var formattedName_ = Network.formatName_(COMPUTE, NETWORK_NAME); + let formattedName_ = Network.formatName_(COMPUTE, NETWORK_NAME); assert.strictEqual(formattedName_, NETWORK_FULL_NAME); }); }); describe('createFirewall', function() { it('should make the correct call to Compute', function(done) { - var name = 'firewall-name'; - var config = {a: 'b', c: 'd'}; - var expectedConfig = extend({}, config, { + let name = 'firewall-name'; + let config = {a: 'b', c: 'd'}; + let expectedConfig = extend({}, config, { network: network.formattedName, }); @@ -162,15 +162,15 @@ describe('Network', function() { describe('createSubnetwork', function() { it('should call region.createSubnetwork correctly', function(done) { - var name = 'subnetwork-name'; - var region = {}; - var config = { + let name = 'subnetwork-name'; + let region = {}; + let config = { a: 'b', c: 'd', region: REGION_NAME, }; - var expectedConfig = extend({}, config, { + let expectedConfig = extend({}, config, { network: network.formattedName, }); delete expectedConfig.region; @@ -202,8 +202,8 @@ describe('Network', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -228,7 +228,7 @@ describe('Network', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -239,7 +239,7 @@ describe('Network', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; network.compute.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -265,15 +265,15 @@ describe('Network', function() { describe('firewall', function() { it('should return a Firewall with the correct metadata', function() { - var name = 'firewall-name'; - var firewall = {}; + let name = 'firewall-name'; + let firewall = {}; network.compute.firewall = function(name_) { assert.strictEqual(name_, name); return firewall; }; - var firewallInstance = network.firewall(name); + let firewallInstance = network.firewall(name); assert.deepStrictEqual(firewallInstance.metadata, { network: network.formattedName, }); @@ -282,8 +282,8 @@ describe('Network', function() { describe('getFirewalls', function() { it('should make the correct call to Compute', function(done) { - var options = {a: 'b', c: 'd'}; - var expectedOptions = extend({}, options, { + let options = {a: 'b', c: 'd'}; + let expectedOptions = extend({}, options, { filter: 'network eq .*' + network.formattedName, }); @@ -306,8 +306,8 @@ describe('Network', function() { describe('getFirewallsStream', function() { it('should call to getFirewallsStream correctly', function(done) { - var options = {a: 'b', c: 'd'}; - var expectedOptions = extend({}, options, { + let options = {a: 'b', c: 'd'}; + let expectedOptions = extend({}, options, { filter: 'network eq .*' + network.formattedName, }); @@ -328,22 +328,22 @@ describe('Network', function() { }); it('should return a stream', function(done) { - var fakeStream = {}; + let fakeStream = {}; network.compute.getFirewallsStream = function() { setImmediate(done); return fakeStream; }; - var stream = network.getFirewallsStream(); + let stream = network.getFirewallsStream(); assert.strictEqual(stream, fakeStream); }); }); describe('getSubnetworks', function() { it('should call to compute.getSubnetworks correctly', function(done) { - var options = {a: 'b', c: 'd'}; - var expectedOptions = extend({}, options, { + let options = {a: 'b', c: 'd'}; + let expectedOptions = extend({}, options, { filter: 'network eq .*' + network.formattedName, }); @@ -366,8 +366,8 @@ describe('Network', function() { describe('getSubnetworksStream', function() { it('should call to getSubnetworksStream correctly', function(done) { - var options = {a: 'b', c: 'd'}; - var expectedOptions = extend({}, options, { + let options = {a: 'b', c: 'd'}; + let expectedOptions = extend({}, options, { filter: 'network eq .*' + network.formattedName, }); @@ -388,14 +388,14 @@ describe('Network', function() { }); it('should return a stream', function(done) { - var fakeStream = {}; + let fakeStream = {}; network.compute.getSubnetworksStream = function() { setImmediate(done); return fakeStream; }; - var stream = network.getSubnetworksStream(); + let stream = network.getSubnetworksStream(); assert.strictEqual(stream, fakeStream); }); }); diff --git a/test/operation.js b/test/operation.js index f82086be..6a464298 100644 --- a/test/operation.js +++ b/test/operation.js @@ -16,10 +16,10 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var proxyquire = require('proxyquire').noPreserveCache(); -var util = require('@google-cloud/common').util; +let assert = require('assert'); +let extend = require('extend'); +let proxyquire = require('proxyquire').noPreserveCache(); +let util = require('@google-cloud/common').util; function FakeOperation() { this.calledWith_ = arguments; @@ -29,9 +29,9 @@ function FakeServiceObject() { this.calledWith_ = arguments; } -var parseHttpRespBodyOverride = null; -var promisified = false; -var fakeUtil = extend({}, util, { +let parseHttpRespBodyOverride = null; +let promisified = false; +let fakeUtil = extend({}, util, { parseHttpRespBody: function() { if (parseHttpRespBodyOverride) { return parseHttpRespBodyOverride.apply(null, arguments); @@ -47,13 +47,13 @@ var fakeUtil = extend({}, util, { }); describe('Operation', function() { - var Operation; - var operation; + let Operation; + let operation; - var SCOPE = { + let SCOPE = { Promise: Promise, }; - var OPERATION_NAME = 'operation-name'; + let OPERATION_NAME = 'operation-name'; before(function() { Operation = proxyquire('../src/operation.js', { @@ -78,7 +78,7 @@ describe('Operation', function() { it('should inherit from Operation', function() { assert(operation instanceof FakeOperation); - var calledWith = operation.calledWith_[0]; + let calledWith = operation.calledWith_[0]; assert.strictEqual(calledWith.parent, SCOPE); assert.strictEqual(calledWith.baseUrl, '/operations'); @@ -95,7 +95,7 @@ describe('Operation', function() { }); it('should give the right baseUrl for a global Operation', function() { - var operation = new Operation( + let operation = new Operation( { constructor: { name: 'Compute', @@ -104,7 +104,7 @@ describe('Operation', function() { OPERATION_NAME ); - var calledWith = operation.calledWith_[0]; + let calledWith = operation.calledWith_[0]; assert.strictEqual(calledWith.baseUrl, '/global/operations'); }); }); @@ -120,8 +120,8 @@ describe('Operation', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.getMetadata = function(callback) { @@ -130,7 +130,7 @@ describe('Operation', function() { }); it('should ignore false errors', function(done) { - var apiResponse = { + let apiResponse = { name: operation.name, error: { errors: [], @@ -166,7 +166,7 @@ describe('Operation', function() { }); describe('success', function() { - var apiResponse = {a: 'b', c: 'd'}; + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.getMetadata = function(callback) { @@ -213,7 +213,7 @@ describe('Operation', function() { }); describe('API error', function() { - var error = new Error('Error.'); + let error = new Error('Error.'); beforeEach(function() { operation.getMetadata = function(callback) { @@ -230,8 +230,8 @@ describe('Operation', function() { }); describe('operation failure', function() { - var error = new Error('Error.'); - var apiResponse = {error: error}; + let error = new Error('Error.'); + let apiResponse = {error: error}; beforeEach(function() { operation.getMetadata = function(callback) { @@ -240,7 +240,7 @@ describe('Operation', function() { }); it('should parse and return the response body', function(done) { - var parsedHttpRespBody = {err: {}}; + let parsedHttpRespBody = {err: {}}; parseHttpRespBodyOverride = function(body) { assert.strictEqual(body, apiResponse); @@ -255,7 +255,7 @@ describe('Operation', function() { }); describe('operation running', function() { - var apiResponse = {status: 'RUNNING'}; + let apiResponse = {status: 'RUNNING'}; beforeEach(function() { operation.getMetadata = function(callback) { @@ -296,7 +296,7 @@ describe('Operation', function() { }); describe('operation complete', function() { - var apiResponse = {status: 'DONE'}; + let apiResponse = {status: 'DONE'}; beforeEach(function() { operation.getMetadata = function(callback) { diff --git a/test/project.js b/test/project.js index 1aadae04..ddb10cf2 100644 --- a/test/project.js +++ b/test/project.js @@ -16,13 +16,13 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var proxyquire = require('proxyquire'); -var util = require('@google-cloud/common').util; +let assert = require('assert'); +let extend = require('extend'); +let proxyquire = require('proxyquire'); +let util = require('@google-cloud/common').util; -var promisified = false; -var fakeUtil = extend({}, util, { +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'Project') { promisified = true; @@ -35,11 +35,11 @@ function FakeServiceObject() { } describe('Project', function() { - var Project; - var project; + let Project; + let project; - var PROJECT_ID = 'project-1'; - var COMPUTE = { + let PROJECT_ID = 'project-1'; + let COMPUTE = { projectId: PROJECT_ID, authConfig: {a: 'b', c: 'd'}, }; @@ -69,7 +69,7 @@ describe('Project', function() { it('should inherit from ServiceObject', function() { assert(project instanceof FakeServiceObject); - var calledWith = project.calledWith_[0]; + let calledWith = project.calledWith_[0]; assert.strictEqual(calledWith.parent, COMPUTE); assert.strictEqual(calledWith.baseUrl, ''); diff --git a/test/region.js b/test/region.js index 3ed53829..ffe648bd 100644 --- a/test/region.js +++ b/test/region.js @@ -16,17 +16,17 @@ 'use strict'; -var arrify = require('arrify'); -var assert = require('assert'); -var common = require('@google-cloud/common'); -var extend = require('extend'); -var is = require('is'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = common.ServiceObject; - -var promisified = false; -var fakeUtil = extend({}, common.util, { +let arrify = require('arrify'); +let assert = require('assert'); +let common = require('@google-cloud/common'); +let extend = require('extend'); +let is = require('is'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = common.ServiceObject; + +let promisified = false; +let fakeUtil = extend({}, common.util, { promisifyAll: function(Class, options) { if (Class.name !== 'Region') { return; @@ -69,8 +69,8 @@ function FakeSubnetwork() { nodeutil.inherits(FakeServiceObject, ServiceObject); -var extended = false; -var fakePaginator = { +let extended = false; +let fakePaginator = { extend: function(Class, methods) { if (Class.name !== 'Region') { return; @@ -92,13 +92,13 @@ var fakePaginator = { }; describe('Region', function() { - var Region; - var region; + let Region; + let region; - var COMPUTE = { + let COMPUTE = { authConfig: {a: 'b', c: 'd'}, }; - var REGION_NAME = 'us-central1'; + let REGION_NAME = 'us-central1'; before(function() { Region = proxyquire('../src/region.js', { @@ -142,7 +142,7 @@ describe('Region', function() { it('should inherit from ServiceObject', function() { assert(region instanceof ServiceObject); - var calledWith = region.calledWith_[0]; + let calledWith = region.calledWith_[0]; assert.strictEqual(calledWith.parent, COMPUTE); assert.strictEqual(calledWith.baseUrl, '/regions'); @@ -156,41 +156,41 @@ describe('Region', function() { describe('request interceptor', function() { it('should assign a request interceptor', function() { - var requestInterceptor = region.interceptors.pop().request; + let requestInterceptor = region.interceptors.pop().request; assert(is.fn(requestInterceptor)); }); it('should strip `/global` from forwardingRules requests', function() { - var reqOpts = { + let reqOpts = { uri: '/compute/v1/projects/projectId/global/forwardingRules', }; - var expectedReqOpts = { + let expectedReqOpts = { uri: '/compute/v1/projects/projectId/forwardingRules', }; - var requestInterceptor = region.interceptors.pop().request; + let requestInterceptor = region.interceptors.pop().request; assert.deepStrictEqual(requestInterceptor(reqOpts), expectedReqOpts); }); it('should not affect non-cancel requests', function() { - var reqOpts = { + let reqOpts = { uri: '/compute/v1/projects/projectId/other/request', }; - var expectedReqOpts = { + let expectedReqOpts = { uri: '/compute/v1/projects/projectId/other/request', }; - var requestInterceptor = region.interceptors.pop().request; + let requestInterceptor = region.interceptors.pop().request; assert.deepStrictEqual(requestInterceptor(reqOpts), expectedReqOpts); }); }); }); describe('address', function() { - var NAME = 'address-name'; + let NAME = 'address-name'; it('should return an Address object', function() { - var address = region.address(NAME); + let address = region.address(NAME); assert(address instanceof FakeAddress); assert.strictEqual(address.calledWith_[0], region); assert.strictEqual(address.calledWith_[1], NAME); @@ -198,12 +198,12 @@ describe('Region', function() { }); describe('createAddress', function() { - var NAME = 'address-name'; - var OPTIONS = {a: 'b', c: 'd'}; - var EXPECTED_BODY = extend({}, OPTIONS, {name: NAME}); + let NAME = 'address-name'; + let OPTIONS = {a: 'b', c: 'd'}; + let EXPECTED_BODY = extend({}, OPTIONS, {name: NAME}); it('should not require any options', function(done) { - var expectedBody = {name: NAME}; + let expectedBody = {name: NAME}; region.request = function(reqOpts) { assert.deepStrictEqual(reqOpts.json, expectedBody); @@ -226,8 +226,8 @@ describe('Region', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { region.request = function(reqOpts, callback) { @@ -247,7 +247,7 @@ describe('Region', function() { }); describe('success', function() { - var apiResponse = {name: 'operation-name'}; + let apiResponse = {name: 'operation-name'}; beforeEach(function() { region.request = function(reqOpts, callback) { @@ -256,8 +256,8 @@ describe('Region', function() { }); it('should exec callback with Address, Op & apiResponse', function(done) { - var address = {}; - var operation = {}; + let address = {}; + let operation = {}; region.address = function(name) { assert.strictEqual(name, NAME); @@ -285,8 +285,8 @@ describe('Region', function() { }); describe('createRule', function() { - var NAME = 'rule-name'; - var CONFIG = {}; + let NAME = 'rule-name'; + let CONFIG = {}; it('should call compute#createRule', function(done) { region.parent.createRule = function(name, config, callback) { @@ -301,13 +301,13 @@ describe('Region', function() { }); describe('createSubnetwork', function() { - var NAME = 'subnetwork-name'; - var CONFIG = { + let NAME = 'subnetwork-name'; + let CONFIG = { a: 'b', c: 'd', network: 'network-name', }; - var EXPECTED_BODY = extend({}, CONFIG, {name: NAME}); + let EXPECTED_BODY = extend({}, CONFIG, {name: NAME}); it('should make the correct API request', function(done) { region.request = function(reqOpts) { @@ -323,10 +323,10 @@ describe('Region', function() { describe('config.network', function() { it('should accept a Network object', function(done) { - var network = new FakeNetwork(); + let network = new FakeNetwork(); network.formattedName = 'formatted-name'; - var config = extend({}, CONFIG, { + let config = extend({}, CONFIG, { network: network, }); @@ -341,7 +341,7 @@ describe('Region', function() { describe('config.range', function() { it('should accept and delete a range property', function(done) { - var config = extend({}, CONFIG, { + let config = extend({}, CONFIG, { range: '...', }); @@ -356,8 +356,8 @@ describe('Region', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { region.request = function(reqOpts, callback) { @@ -377,7 +377,7 @@ describe('Region', function() { }); describe('success', function() { - var apiResponse = {name: 'operation-name'}; + let apiResponse = {name: 'operation-name'}; beforeEach(function() { region.request = function(reqOpts, callback) { @@ -386,8 +386,8 @@ describe('Region', function() { }); it('should exec cb with Subnetwork, Op & apiResponse', function(done) { - var subnetwork = {}; - var operation = {}; + let subnetwork = {}; + let operation = {}; region.subnetwork = function(name) { assert.strictEqual(name, NAME); @@ -425,7 +425,7 @@ describe('Region', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; region.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/addresses'); @@ -438,8 +438,8 @@ describe('Region', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { region.request = function(reqOpts, callback) { @@ -459,7 +459,7 @@ describe('Region', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{name: 'operation-name'}], }; @@ -470,11 +470,11 @@ describe('Region', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -492,7 +492,7 @@ describe('Region', function() { }); it('should execute callback with Operations & API resp', function(done) { - var address = {}; + let address = {}; region.address = function(name) { assert.strictEqual(name, apiResponse.items[0].name); @@ -524,7 +524,7 @@ describe('Region', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; region.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/operations'); @@ -537,8 +537,8 @@ describe('Region', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { region.request = function(reqOpts, callback) { @@ -558,7 +558,7 @@ describe('Region', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{name: 'operation-name'}], }; @@ -569,11 +569,11 @@ describe('Region', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -591,7 +591,7 @@ describe('Region', function() { }); it('should execute callback with Operations & API resp', function(done) { - var operation = {}; + let operation = {}; region.operation = function(name) { assert.strictEqual(name, apiResponse.items[0].name); @@ -623,7 +623,7 @@ describe('Region', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; region.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/forwardingRules'); @@ -636,8 +636,8 @@ describe('Region', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { region.request = function(reqOpts, callback) { @@ -657,7 +657,7 @@ describe('Region', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{name: 'operation-name'}], }; @@ -668,11 +668,11 @@ describe('Region', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -690,7 +690,7 @@ describe('Region', function() { }); it('should execute callback with Operations & API resp', function(done) { - var rule = {}; + let rule = {}; region.rule = function(name) { assert.strictEqual(name, apiResponse.items[0].name); @@ -722,7 +722,7 @@ describe('Region', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; region.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/subnetworks'); @@ -735,8 +735,8 @@ describe('Region', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { region.request = function(reqOpts, callback) { @@ -756,7 +756,7 @@ describe('Region', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{name: 'subnetwork-name'}], }; @@ -767,11 +767,11 @@ describe('Region', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -789,7 +789,7 @@ describe('Region', function() { }); it('should execute callback with Operations & API resp', function(done) { - var subnetwork = {}; + let subnetwork = {}; region.subnetwork = function(name) { assert.strictEqual(name, apiResponse.items[0].name); @@ -811,10 +811,10 @@ describe('Region', function() { }); describe('operation', function() { - var NAME = 'operation-name'; + let NAME = 'operation-name'; it('should return a Operation object', function() { - var operation = region.operation(NAME); + let operation = region.operation(NAME); assert(operation instanceof FakeOperation); assert.strictEqual(operation.calledWith_[0], region); assert.strictEqual(operation.calledWith_[1], NAME); @@ -822,10 +822,10 @@ describe('Region', function() { }); describe('rule', function() { - var NAME = 'rule-name'; + let NAME = 'rule-name'; it('should return a Operation object', function() { - var rule = region.rule(NAME); + let rule = region.rule(NAME); assert(rule instanceof FakeRule); assert.strictEqual(rule.calledWith_[0], region); assert.strictEqual(rule.calledWith_[1], NAME); @@ -833,10 +833,10 @@ describe('Region', function() { }); describe('subnetwork', function() { - var NAME = 'subnetwork-name'; + let NAME = 'subnetwork-name'; it('should return a Subnetwork object', function() { - var subnetwork = region.subnetwork(NAME); + let subnetwork = region.subnetwork(NAME); assert(subnetwork instanceof FakeSubnetwork); assert.strictEqual(subnetwork.calledWith_[0], region); assert.strictEqual(subnetwork.calledWith_[1], NAME); diff --git a/test/rule.js b/test/rule.js index 2866b2d2..5bdcc11b 100644 --- a/test/rule.js +++ b/test/rule.js @@ -16,13 +16,13 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var proxyquire = require('proxyquire'); -var util = require('@google-cloud/common').util; +let assert = require('assert'); +let extend = require('extend'); +let proxyquire = require('proxyquire'); +let util = require('@google-cloud/common').util; -var promisified = false; -var fakeUtil = extend({}, util, { +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'Rule') { promisified = true; @@ -35,16 +35,16 @@ function FakeServiceObject() { } describe('Rule', function() { - var Rule; - var rule; + let Rule; + let rule; function Compute() { this.createRule = util.noop; this.operation = util.noop; } - var COMPUTE = new Compute(); - var RULE_NAME = 'rule-name'; + let COMPUTE = new Compute(); + let RULE_NAME = 'rule-name'; before(function() { Rule = proxyquire('../src/rule.js', { @@ -61,8 +61,8 @@ describe('Rule', function() { describe('instantiation', function() { it('should inherit from ServiceObject', function() { - var computeInstance = new Compute(); - var bindMethod = {}; + let computeInstance = new Compute(); + let bindMethod = {}; extend(computeInstance, { createRule: { @@ -73,10 +73,10 @@ describe('Rule', function() { }, }); - var rule = new Rule(computeInstance, RULE_NAME); + let rule = new Rule(computeInstance, RULE_NAME); assert(rule instanceof FakeServiceObject); - var calledWith = rule.calledWith_[0]; + let calledWith = rule.calledWith_[0]; assert.strictEqual(calledWith.parent, computeInstance); assert.strictEqual(calledWith.baseUrl, '/global/forwardingRules'); @@ -95,10 +95,10 @@ describe('Rule', function() { }); it('should not use global forwarding rules', function() { - var rule = new Rule({createRule: util.noop}, RULE_NAME); + let rule = new Rule({createRule: util.noop}, RULE_NAME); assert(rule instanceof FakeServiceObject); - var calledWith = rule.calledWith_[0]; + let calledWith = rule.calledWith_[0]; assert.strictEqual(calledWith.baseUrl, '/forwardingRules'); }); @@ -119,8 +119,8 @@ describe('Rule', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -145,7 +145,7 @@ describe('Rule', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -156,7 +156,7 @@ describe('Rule', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; rule.scope.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -181,7 +181,7 @@ describe('Rule', function() { }); describe('setTarget', function() { - var TARGET = 'target'; + let TARGET = 'target'; it('should make the correct API request', function(done) { rule.request = function(reqOpts) { @@ -196,8 +196,8 @@ describe('Rule', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {}; + let error = new Error('Error.'); + let apiResponse = {}; beforeEach(function() { rule.request = function(reqOpts, callback) { @@ -216,7 +216,7 @@ describe('Rule', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -227,7 +227,7 @@ describe('Rule', function() { }); it('should execute callback with operation & response', function(done) { - var operation = {}; + let operation = {}; rule.scope.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/service.js b/test/service.js index 824e740b..822cea22 100644 --- a/test/service.js +++ b/test/service.js @@ -16,15 +16,15 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let assert = require('assert'); +let extend = require('extend'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'Service') { promisified = true; @@ -40,12 +40,12 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Service', function() { - var Service; - var service; + let Service; + let service; - var SERVICE_NAME = 'service-name'; + let SERVICE_NAME = 'service-name'; - var COMPUTE = { + let COMPUTE = { projectId: 'project-id', createService: util.noop, }; @@ -77,7 +77,7 @@ describe('Service', function() { }); it('should inherit from ServiceObject', function() { - var createMethod = util.noop; + let createMethod = util.noop; var computeInstance = extend({}, COMPUTE, { createService: { @@ -88,10 +88,10 @@ describe('Service', function() { }, }); - var service = new Service(computeInstance, SERVICE_NAME); + let service = new Service(computeInstance, SERVICE_NAME); assert(service instanceof ServiceObject); - var calledWith = service.calledWith_[0]; + let calledWith = service.calledWith_[0]; assert.strictEqual(calledWith.parent, computeInstance); assert.strictEqual(calledWith.baseUrl, '/global/backendServices'); @@ -117,8 +117,8 @@ describe('Service', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -143,7 +143,7 @@ describe('Service', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -154,7 +154,7 @@ describe('Service', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; service.compute.operation = function(name) { assert.strictEqual(name, apiResponse.name); @@ -179,7 +179,7 @@ describe('Service', function() { }); describe('getHealth', function() { - var GROUP = 'http://group-url'; + let GROUP = 'http://group-url'; it('should make the correct request', function(done) { service.request = function(reqOpts) { @@ -197,7 +197,7 @@ describe('Service', function() { describe('group object', function() { it('should compose the right URL', function(done) { - var group = { + let group = { name: 'instance-group-name', zone: 'zone-name', }; @@ -221,7 +221,7 @@ describe('Service', function() { }); it('should compose the right URL', function(done) { - var group = { + let group = { name: 'instance-group-name', // Simulating a {module:compute/zone}: zone: { @@ -249,8 +249,8 @@ describe('Service', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { service.request = function(reqOpts, callback) { @@ -269,7 +269,7 @@ describe('Service', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { healthStatus: {}, }; @@ -292,7 +292,7 @@ describe('Service', function() { describe('setMetadata', function() { it('should make the correct API request', function(done) { - var metadata = {}; + let metadata = {}; service.request = function(reqOpts) { assert.strictEqual(reqOpts.method, 'PATCH'); @@ -306,8 +306,8 @@ describe('Service', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { service.request = function(reqOpts, callback) { @@ -326,7 +326,7 @@ describe('Service', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -337,8 +337,8 @@ describe('Service', function() { }); it('should execute callback with operation & response', function(done) { - var operation = {}; - var metadata = {a: 'b'}; + let operation = {}; + let metadata = {a: 'b'}; service.compute.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/snapshot.js b/test/snapshot.js index 54c09ba3..783b0c5e 100644 --- a/test/snapshot.js +++ b/test/snapshot.js @@ -16,15 +16,15 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var common = require('@google-cloud/common'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = common.ServiceObject; - -var promisified = false; -var fakeUtil = extend({}, common.util, { +let assert = require('assert'); +let extend = require('extend'); +let common = require('@google-cloud/common'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = common.ServiceObject; + +let promisified = false; +let fakeUtil = extend({}, common.util, { promisifyAll: function(Class) { if (Class.name === 'Snapshot') { promisified = true; @@ -40,11 +40,11 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Snapshot', function() { - var Snapshot; - var snapshot; + let Snapshot; + let snapshot; - var COMPUTE = {}; - var SNAPSHOT_NAME = 'snapshot-name'; + let COMPUTE = {}; + let SNAPSHOT_NAME = 'snapshot-name'; before(function() { Snapshot = proxyquire('../src/snapshot.js', { @@ -69,7 +69,7 @@ describe('Snapshot', function() { }); it('should inherit from ServiceObject', function() { - var calledWith = snapshot.calledWith_[0]; + let calledWith = snapshot.calledWith_[0]; assert.strictEqual(calledWith.parent, COMPUTE); assert.strictEqual( @@ -99,10 +99,10 @@ describe('Snapshot', function() { }, }; - var snapshot = new Snapshot(scope, SNAPSHOT_NAME); + let snapshot = new Snapshot(scope, SNAPSHOT_NAME); assert(snapshot instanceof ServiceObject); - var calledWith = snapshot.calledWith_[0]; + let calledWith = snapshot.calledWith_[0]; assert.strictEqual(calledWith.methods.create, true); calledWith.createMethod(); // (scope.createSnapshot) @@ -120,8 +120,8 @@ describe('Snapshot', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -146,7 +146,7 @@ describe('Snapshot', function() { }); describe('success', function() { - var apiResponse = {name: 'operation-name'}; + let apiResponse = {name: 'operation-name'}; beforeEach(function() { FakeServiceObject.prototype.delete = function(callback) { @@ -155,7 +155,7 @@ describe('Snapshot', function() { }); it('should exec callback with Operation & API response', function(done) { - var operation = {}; + let operation = {}; snapshot.compute.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/subnetwork.js b/test/subnetwork.js index 3948fc41..e3826389 100644 --- a/test/subnetwork.js +++ b/test/subnetwork.js @@ -16,15 +16,15 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let assert = require('assert'); +let extend = require('extend'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'Subnetwork') { promisified = true; @@ -40,12 +40,12 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Subnetwork', function() { - var Subnetwork; - var subnetwork; + let Subnetwork; + let subnetwork; - var SUBNETWORK_NAME = 'subnetwork_name'; - var REGION_NAME = 'region-1'; - var REGION = { + let SUBNETWORK_NAME = 'subnetwork_name'; + let REGION_NAME = 'region-1'; + let REGION = { createSubnetwork: util.noop, name: REGION_NAME, }; @@ -73,7 +73,7 @@ describe('Subnetwork', function() { }); it('should inherit from ServiceObject', function() { - var createSubnetworkBound = {}; + let createSubnetworkBound = {}; var regionInstance = extend({}, REGION, { createSubnetwork: { @@ -84,10 +84,10 @@ describe('Subnetwork', function() { }, }); - var subnetwork = new Subnetwork(regionInstance, SUBNETWORK_NAME); + let subnetwork = new Subnetwork(regionInstance, SUBNETWORK_NAME); assert(subnetwork instanceof ServiceObject); - var calledWith = subnetwork.calledWith_[0]; + let calledWith = subnetwork.calledWith_[0]; assert.strictEqual(calledWith.parent, regionInstance); assert.strictEqual(calledWith.baseUrl, '/subnetworks'); @@ -118,8 +118,8 @@ describe('Subnetwork', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { subnetwork.request = function(reqOpts, callback) { @@ -144,7 +144,7 @@ describe('Subnetwork', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { name: 'op-name', }; @@ -155,7 +155,7 @@ describe('Subnetwork', function() { }); it('should execute callback with Operation & Response', function(done) { - var operation = {}; + let operation = {}; subnetwork.region.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/vm.js b/test/vm.js index b4d38f65..a904dc78 100644 --- a/test/vm.js +++ b/test/vm.js @@ -16,17 +16,17 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; +let assert = require('assert'); +let extend = require('extend'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; -var utilCached = extend({}, util); +let utilCached = extend({}, util); -var promisified = false; -var fakeUtil = extend({}, util, { +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'VM') { promisified = true; @@ -42,26 +42,26 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('VM', function() { - var VM; - var vm; + let VM; + let vm; - var Disk; - var DISK; + let Disk; + let DISK; - var COMPUTE = { + let COMPUTE = { authClient: { projectId: 'project-id', }, projectId: 'project-id', }; - var ZONE = { + let ZONE = { compute: COMPUTE, name: 'us-central1-a', createDisk: util.noop, createVM: util.noop, }; - var VM_NAME = 'vm-name'; - var FULLY_QUALIFIED_NAME = [ + let VM_NAME = 'vm-name'; + let FULLY_QUALIFIED_NAME = [ 'project/project-id/zones/zone-name/instances/', VM_NAME, ].join(''); @@ -96,7 +96,7 @@ describe('VM', function() { }); it('should strip a qualified name to just the instance name', function() { - var vm = new VM(ZONE, FULLY_QUALIFIED_NAME); + let vm = new VM(ZONE, FULLY_QUALIFIED_NAME); assert.strictEqual(vm.name, VM_NAME); }); @@ -132,10 +132,10 @@ describe('VM', function() { }, }); - var vm = new VM(zoneInstance, VM_NAME); + let vm = new VM(zoneInstance, VM_NAME); assert(vm instanceof ServiceObject); - var calledWith = vm.calledWith_[0]; + let calledWith = vm.calledWith_[0]; assert.strictEqual(calledWith.parent, zoneInstance); assert.strictEqual(calledWith.baseUrl, '/instances'); @@ -150,8 +150,8 @@ describe('VM', function() { }); describe('attachDisk', function() { - var CONFIG = {}; - var EXPECTED_BODY; + let CONFIG = {}; + let EXPECTED_BODY; beforeEach(function() { EXPECTED_BODY = { @@ -184,7 +184,7 @@ describe('VM', function() { var CONFIG = extend({}, CONFIG, {readOnly: true}); it('should set the correct mode', function(done) { - var expectedBody = extend({}, EXPECTED_BODY, {mode: 'READ_ONLY'}); + let expectedBody = extend({}, EXPECTED_BODY, {mode: 'READ_ONLY'}); vm.request = function(reqOpts) { assert.deepStrictEqual(reqOpts.json, expectedBody); @@ -242,8 +242,8 @@ describe('VM', function() { }); describe('detachDisk', function() { - var DEVICE_NAME; - var METADATA; + let DEVICE_NAME; + let METADATA; beforeEach(function() { DEVICE_NAME = DISK.formattedName; @@ -274,7 +274,7 @@ describe('VM', function() { }); it('should replace projectId token in disk name', function(done) { - var REPLACED_DEVICE_NAME = 'replaced-device-name'; + let REPLACED_DEVICE_NAME = 'replaced-device-name'; fakeUtil.replaceProjectIdToken = function(value, projectId) { assert.strictEqual(value, DISK.formattedName); @@ -283,7 +283,7 @@ describe('VM', function() { }; vm.getMetadata = function(callback) { - var metadata = { + let metadata = { disks: [ { source: REPLACED_DEVICE_NAME, @@ -304,7 +304,7 @@ describe('VM', function() { }); it('should return an error if device name not found', function(done) { - var metadata = { + let metadata = { disks: [ { source: 'a', @@ -320,7 +320,7 @@ describe('VM', function() { vm.detachDisk(DISK, function(err) { assert.strictEqual(err.name, 'DetachDiskError'); - var errorMessage = 'Device name for this disk was not found.'; + let errorMessage = 'Device name for this disk was not found.'; assert.strictEqual(err.message, errorMessage); done(); @@ -352,7 +352,7 @@ describe('VM', function() { describe('refreshing metadata', function() { describe('error', function() { - var ERROR = new Error('Error.'); + let ERROR = new Error('Error.'); beforeEach(function() { vm.getMetadata = function(callback) { @@ -372,7 +372,7 @@ describe('VM', function() { }); describe('getSerialPortOutput', function() { - var EXPECTED_QUERY = {port: 1}; + let EXPECTED_QUERY = {port: 1}; it('should default to port 1', function(done) { FakeServiceObject.prototype.request = function(reqOpts) { @@ -384,7 +384,7 @@ describe('VM', function() { }); it('should override the default port', function(done) { - var port = 8001; + let port = 8001; FakeServiceObject.prototype.request = function(reqOpts) { assert.strictEqual(reqOpts.qs.port, port); @@ -406,8 +406,8 @@ describe('VM', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.request = function(reqOpts, callback) { @@ -427,7 +427,7 @@ describe('VM', function() { }); describe('success', function() { - var apiResponse = {contents: 'contents'}; + let apiResponse = {contents: 'contents'}; beforeEach(function() { FakeServiceObject.prototype.request = function(reqOpts, callback) { @@ -457,8 +457,8 @@ describe('VM', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { vm.getMetadata = function(callback) { @@ -479,14 +479,14 @@ describe('VM', function() { }); describe('success', function() { - var metadata = { + let metadata = { tags: { items: [], fingerprint: 'fingerprint', }, }; - var apiResponse = {a: 'b', c: 'd'}; + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { vm.getMetadata = function(callback) { @@ -533,7 +533,7 @@ describe('VM', function() { }); describe('resize', function() { - var MACHINE_TYPE = 'zones/' + ZONE.name + '/machineTypes/machineType'; + let MACHINE_TYPE = 'zones/' + ZONE.name + '/machineTypes/machineType'; beforeEach(function() { vm.request = util.noop; @@ -557,7 +557,7 @@ describe('VM', function() { }); it('should allow a partial machine type', function(done) { - var partialMachineType = MACHINE_TYPE.split('/').pop(); + let partialMachineType = MACHINE_TYPE.split('/').pop(); vm.request = function(reqOpts) { assert.strictEqual(reqOpts.method, 'POST'); @@ -573,7 +573,7 @@ describe('VM', function() { describe('error', function() { describe('instance is running', function() { - var error = new Error('Instance is starting or running.'); + let error = new Error('Instance is starting or running.'); beforeEach(function() { vm.zone.parent.execAfterOperation_ = function(callback) { @@ -591,8 +591,8 @@ describe('VM', function() { }); describe('stopping failed', function() { - var vmStopError = new Error('Error.'); - var apiResponse = {}; + let vmStopError = new Error('Error.'); + let apiResponse = {}; beforeEach(function() { // First: vm.request() @@ -652,8 +652,8 @@ describe('VM', function() { }); describe('instance is stopped', function() { - var error = new Error('Error'); - var apiResponse = {}; + let error = new Error('Error'); + let apiResponse = {}; beforeEach(function() { vm.zone.parent.execAfterOperation_ = function(callback) { @@ -697,7 +697,7 @@ describe('VM', function() { }); it('should not start the VM by request', function(done) { - var apiResponse = {}; + let apiResponse = {}; vm.zone.parent.execAfterOperation_ = function(callback) { callback(null, apiResponse); @@ -716,14 +716,14 @@ describe('VM', function() { }); describe('setMetadata', function() { - var METADATA = { + let METADATA = { newKey: 'newValue', }; describe('getting the current fingerprint', function() { describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {}; + let error = new Error('Error.'); + let apiResponse = {}; beforeEach(function() { vm.getMetadata = function(callback) { @@ -742,13 +742,13 @@ describe('VM', function() { }); describe('success', function() { - var metadata = { + let metadata = { metadata: { fingerprint: '===', }, }; - var apiResponse = {}; + let apiResponse = {}; beforeEach(function() { vm.getMetadata = function(callback) { @@ -757,7 +757,7 @@ describe('VM', function() { }); it('should make the correct request', function(done) { - var expectedNewMetadata = extend(true, {}, metadata.metadata, { + let expectedNewMetadata = extend(true, {}, metadata.metadata, { items: [ { key: 'newKey', @@ -782,8 +782,8 @@ describe('VM', function() { }); describe('setTags', function() { - var TAGS = []; - var FINGERPRINT = ''; + let TAGS = []; + let FINGERPRINT = ''; it('should make the correct request', function(done) { vm.request = function(reqOpts, callback) { @@ -857,7 +857,7 @@ describe('VM', function() { }); describe('waitFor', function() { - var VALID_STATUSES = [ + let VALID_STATUSES = [ 'PROVISIONING', 'STAGING', 'RUNNING', @@ -901,10 +901,10 @@ describe('VM', function() { }); it('should create a waiter', function(done) { - var now = new Date() / 1000; + let now = new Date() / 1000; vm.waitFor(VALID_STATUSES[0], done); - var createdWaiter = vm.waiters.pop(); + let createdWaiter = vm.waiters.pop(); assert.strictEqual(createdWaiter.status, VALID_STATUSES[0]); assert.strictEqual(createdWaiter.timeout, 300); @@ -940,7 +940,7 @@ describe('VM', function() { }); describe('startPolling_', function() { - var METADATA = {}; + let METADATA = {}; beforeEach(function() { vm.hasActiveWaiters = true; @@ -970,7 +970,7 @@ describe('VM', function() { }); describe('metadata refresh error', function() { - var ERROR = new Error('Error.'); + let ERROR = new Error('Error.'); beforeEach(function() { vm.getMetadata = function(callback) { @@ -1005,8 +1005,8 @@ describe('VM', function() { }); describe('desired status reached', function() { - var STATUS = 'status'; - var METADATA = { + let STATUS = 'status'; + let METADATA = { status: STATUS, }; @@ -1045,7 +1045,7 @@ describe('VM', function() { }); describe('timeout exceeded', function() { - var STATUS = 'status'; + let STATUS = 'status'; beforeEach(function() { vm.waiters.push({ @@ -1087,8 +1087,8 @@ describe('VM', function() { }); describe('desired status not reached yet', function() { - var STATUS = 'status'; - var setTimeout = global.setTimeout; + let STATUS = 'status'; + let setTimeout = global.setTimeout; beforeEach(function() { vm.waiters.push({ @@ -1123,7 +1123,7 @@ describe('VM', function() { describe('request', function() { it('should make the correct request to Compute', function(done) { - var reqOpts = {}; + let reqOpts = {}; FakeServiceObject.prototype.request = function(reqOpts_) { assert.strictEqual(this, vm); @@ -1136,8 +1136,8 @@ describe('VM', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { FakeServiceObject.prototype.request = function(reqOpts, callback) { @@ -1156,7 +1156,7 @@ describe('VM', function() { }); describe('success', function() { - var apiResponse = {name: 'operation-name'}; + let apiResponse = {name: 'operation-name'}; beforeEach(function() { FakeServiceObject.prototype.request = function(reqOpts, callback) { @@ -1165,7 +1165,7 @@ describe('VM', function() { }); it('should execute callback with Zone object & API resp', function(done) { - var operation = {}; + let operation = {}; vm.zone.operation = function(name) { assert.strictEqual(name, apiResponse.name); diff --git a/test/zone.js b/test/zone.js index 5d7e0e04..cd041edf 100644 --- a/test/zone.js +++ b/test/zone.js @@ -16,17 +16,17 @@ 'use strict'; -var arrify = require('arrify'); -var assert = require('assert'); -var extend = require('extend'); -var gceImages = require('gce-images'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +let arrify = require('arrify'); +let assert = require('assert'); +let extend = require('extend'); +let gceImages = require('gce-images'); +let nodeutil = require('util'); +let proxyquire = require('proxyquire'); +let ServiceObject = require('@google-cloud/common').ServiceObject; +let util = require('@google-cloud/common').util; + +let promisified = false; +let fakeUtil = extend({}, util, { promisifyAll: function(Class, options) { if (Class.name !== 'Zone') { return; @@ -44,7 +44,7 @@ var fakeUtil = extend({}, util, { }, }); -var gceImagesOverride; +let gceImagesOverride; function fakeGceImages() { return (gceImagesOverride || gceImages).apply(null, arguments); } @@ -57,7 +57,7 @@ function FakeDisk() { this.calledWith_ = [].slice.call(arguments); } -var formatPortsOverride; +let formatPortsOverride; FakeInstanceGroup.formatPorts_ = function() { return (formatPortsOverride || util.noop).apply(null, arguments); }; @@ -85,8 +85,8 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); -var extended = false; -var fakePaginator = { +let extended = false; +let fakePaginator = { extend: function(Class, methods) { if (Class.name !== 'Zone') { return; @@ -110,14 +110,14 @@ var fakePaginator = { }; describe('Zone', function() { - var Zone; - var zone; + let Zone; + let zone; - var COMPUTE = { + let COMPUTE = { authClient: {}, projectId: 'project-id', }; - var ZONE_NAME = 'us-central1-a'; + let ZONE_NAME = 'us-central1-a'; before(function() { Zone = proxyquire('../src/zone.js', { @@ -169,21 +169,21 @@ describe('Zone', function() { }); it('should create a gceImages instance', function() { - var gceVal = 'ok'; + let gceVal = 'ok'; gceImagesOverride = function(authConfig) { assert.strictEqual(authConfig.authClient, COMPUTE.authClient); return gceVal; }; - var newZone = new Zone(COMPUTE, ZONE_NAME); + let newZone = new Zone(COMPUTE, ZONE_NAME); assert.strictEqual(newZone.gceImages, gceVal); }); it('should inherit from ServiceObject', function() { assert(zone instanceof ServiceObject); - var calledWith = zone.calledWith_[0]; + let calledWith = zone.calledWith_[0]; assert.strictEqual(calledWith.parent, COMPUTE); assert.strictEqual(calledWith.baseUrl, '/zones'); @@ -197,10 +197,10 @@ describe('Zone', function() { }); describe('autoscaler', function() { - var NAME = 'autoscaler-name'; + let NAME = 'autoscaler-name'; it('should return an Autoscaler object', function() { - var autoscaler = zone.autoscaler(NAME); + let autoscaler = zone.autoscaler(NAME); assert(autoscaler instanceof FakeAutoscaler); assert.strictEqual(autoscaler.calledWith_[0], zone); assert.strictEqual(autoscaler.calledWith_[1], NAME); @@ -208,8 +208,8 @@ describe('Zone', function() { }); describe('createAutoscaler', function() { - var NAME = 'autoscaler-name'; - var TARGET = 'target'; + let NAME = 'autoscaler-name'; + let TARGET = 'target'; beforeEach(function() { zone.request = util.noop; @@ -222,7 +222,7 @@ describe('Zone', function() { }); it('should make the correct request', function(done) { - var config = { + let config = { target: TARGET, }; @@ -235,7 +235,7 @@ describe('Zone', function() { }); it('should use a provided autoscalingPolicy', function(done) { - var config = { + let config = { autoscalingPolicy: { a: 'b', c: 'd', @@ -244,7 +244,7 @@ describe('Zone', function() { }; zone.request = function(reqOpts) { - var policy = reqOpts.json.autoscalingPolicy; + let policy = reqOpts.json.autoscalingPolicy; assert.deepStrictEqual(policy, config.autoscalingPolicy); done(); }; @@ -254,7 +254,7 @@ describe('Zone', function() { describe('config.target', function() { it('should use a provided http target', function(done) { - var config = { + let config = { target: 'http://my-target', }; @@ -267,7 +267,7 @@ describe('Zone', function() { }); it('should use a provided https target', function(done) { - var config = { + let config = { target: 'https://my-target', }; @@ -280,12 +280,12 @@ describe('Zone', function() { }); it('should create a full target URL', function(done) { - var config = { + let config = { target: 'my-target', }; zone.request = function(reqOpts) { - var expectedTarget = [ + let expectedTarget = [ 'https://content.googleapis.com/compute/v1/projects/', COMPUTE.projectId, '/zones/', @@ -305,13 +305,13 @@ describe('Zone', function() { describe('config.coolDown', function() { it('should set coolDownPeriodSec', function(done) { - var config = { + let config = { coolDown: 80, target: TARGET, }; zone.request = function(reqOpts) { - var policy = reqOpts.json.autoscalingPolicy; + let policy = reqOpts.json.autoscalingPolicy; assert.strictEqual(policy.coolDownPeriodSec, config.coolDown); assert.strictEqual(reqOpts.coolDown, undefined); done(); @@ -323,14 +323,14 @@ describe('Zone', function() { describe('config.cpu', function() { it('should set cpuUtilization', function(done) { - var config = { + let config = { cpu: 80, target: TARGET, }; zone.request = function(reqOpts) { - var policy = reqOpts.json.autoscalingPolicy; - var cpu = policy.cpuUtilization; + let policy = reqOpts.json.autoscalingPolicy; + let cpu = policy.cpuUtilization; assert.strictEqual(cpu.utilizationTarget, config.cpu / 100); assert.strictEqual(reqOpts.cpu, undefined); done(); @@ -342,14 +342,14 @@ describe('Zone', function() { describe('config.loadBalance', function() { it('should set loadBalancingUtilization', function(done) { - var config = { + let config = { loadBalance: 80, target: TARGET, }; zone.request = function(reqOpts) { - var policy = reqOpts.json.autoscalingPolicy; - var lb = policy.loadBalancingUtilization; + let policy = reqOpts.json.autoscalingPolicy; + let lb = policy.loadBalancingUtilization; assert.strictEqual(lb.utilizationTarget, config.loadBalance / 100); assert.strictEqual(reqOpts.loadBalance, undefined); done(); @@ -361,13 +361,13 @@ describe('Zone', function() { describe('config.maxReplicas', function() { it('should set maxNumReplicas', function(done) { - var config = { + let config = { maxReplicas: 10, target: TARGET, }; zone.request = function(reqOpts) { - var policy = reqOpts.json.autoscalingPolicy; + let policy = reqOpts.json.autoscalingPolicy; assert.strictEqual(policy.maxNumReplicas, config.maxReplicas); assert.strictEqual(reqOpts.maxReplicas, undefined); done(); @@ -379,13 +379,13 @@ describe('Zone', function() { describe('config.minReplicas', function() { it('should set minNumReplicas', function(done) { - var config = { + let config = { minReplicas: 10, target: TARGET, }; zone.request = function(reqOpts) { - var policy = reqOpts.json.autoscalingPolicy; + let policy = reqOpts.json.autoscalingPolicy; assert.strictEqual(policy.minNumReplicas, config.minReplicas); assert.strictEqual(reqOpts.minReplicas, undefined); done(); @@ -396,13 +396,13 @@ describe('Zone', function() { }); describe('API request', function() { - var CONFIG = { + let CONFIG = { a: 'b', c: 'd', target: 'http://target', }; - var expectedBody = { + let expectedBody = { name: NAME, target: 'http://target', autoscalingPolicy: {}, @@ -423,8 +423,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -444,7 +444,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = {name: 'operation-name'}; + let apiResponse = {name: 'operation-name'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -453,8 +453,8 @@ describe('Zone', function() { }); it('should exec callback with AutoS, Op & apiResponse', function(done) { - var autoscaler = {}; - var operation = {}; + let autoscaler = {}; + let operation = {}; zone.autoscaler = function(name) { assert.strictEqual(name, NAME); @@ -483,14 +483,14 @@ describe('Zone', function() { }); describe('createDisk', function() { - var NAME = 'disk-name'; + let NAME = 'disk-name'; beforeEach(function() { zone.request = util.noop; }); it('should use the image property as qs.sourceImages', function(done) { - var config = { + let config = { image: 'abc', }; @@ -503,7 +503,7 @@ describe('Zone', function() { }); describe('config.os', function() { - var CONFIG = { + let CONFIG = { os: 'os-name', }; @@ -517,7 +517,7 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); + let error = new Error('Error.'); beforeEach(function() { zone.gceImages.getLatest = function(os, callback) { @@ -534,11 +534,11 @@ describe('Zone', function() { }); describe('success', function() { - var gceImagesResp = { + let gceImagesResp = { selfLink: 'http://selflink', }; - var expectedConfig = { + let expectedConfig = { name: NAME, sourceImage: gceImagesResp.selfLink, }; @@ -560,12 +560,12 @@ describe('Zone', function() { }); describe('API request', function() { - var CONFIG = { + let CONFIG = { a: 'b', c: 'd', }; - var expectedBody = { + let expectedBody = { name: NAME, a: 'b', c: 'd', @@ -585,8 +585,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -606,7 +606,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = {name: 'operation-name'}; + let apiResponse = {name: 'operation-name'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -615,8 +615,8 @@ describe('Zone', function() { }); it('should exec callback with Disk, Op & apiResponse', function(done) { - var disk = {}; - var operation = {}; + let disk = {}; + let operation = {}; zone.disk = function(name) { assert.strictEqual(name, NAME); @@ -645,20 +645,20 @@ describe('Zone', function() { }); describe('createInstanceGroup', function() { - var NAME = 'instance-group'; + let NAME = 'instance-group'; beforeEach(function() { zone.request = util.noop; }); describe('options.ports', function() { - var PORTS = { + let PORTS = { http: 80, https: 443, }; it('should format named ports', function(done) { - var expectedNamedPorts = []; + let expectedNamedPorts = []; formatPortsOverride = function(ports) { assert.strictEqual(ports, PORTS); @@ -676,12 +676,12 @@ describe('Zone', function() { }); describe('API request', function() { - var OPTIONS = { + let OPTIONS = { a: 'b', c: 'd', }; - var expectedBody = { + let expectedBody = { name: NAME, a: 'b', c: 'd', @@ -709,8 +709,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -730,7 +730,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = {name: 'operation-name'}; + let apiResponse = {name: 'operation-name'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -739,8 +739,8 @@ describe('Zone', function() { }); it('should exec callback with Group, Op & apiResponse', function(done) { - var instanceGroup = {}; - var operation = {}; + let instanceGroup = {}; + let operation = {}; zone.instanceGroup = function(name) { assert.strictEqual(name, NAME); @@ -769,11 +769,11 @@ describe('Zone', function() { }); describe('createVM', function() { - var NAME = 'new-vm'; + let NAME = 'new-vm'; - var CONFIG = {}; + let CONFIG = {}; - var EXPECTED_CONFIG = { + let EXPECTED_CONFIG = { name: NAME, machineType: 'zones/' + ZONE_NAME + '/machineTypes/n1-standard-1', networkInterfaces: [ @@ -784,7 +784,7 @@ describe('Zone', function() { }; describe('config.machineType', function() { - var CONFIG = { + let CONFIG = { machineType: 'f1-micro', }; @@ -802,7 +802,7 @@ describe('Zone', function() { }); describe('config.tags', function() { - var CONFIG = { + let CONFIG = { tags: ['a', 'b'], }; @@ -817,7 +817,7 @@ describe('Zone', function() { }); describe('config.http', function() { - var CONFIG = { + let CONFIG = { http: true, }; @@ -828,7 +828,7 @@ describe('Zone', function() { }); it('should execute cb with error from creating firewall', function(done) { - var error = new Error('Error.'); + let error = new Error('Error.'); zone.createHttpServerFirewall_ = function(callback) { callback(error); @@ -872,14 +872,14 @@ describe('Zone', function() { }); it('should not overwrite existing tags', function(done) { - var config = { + let config = { http: true, tags: { items: ['a', 'b'], }, }; - var expectedTags = ['a', 'b', 'http-server']; + let expectedTags = ['a', 'b', 'http-server']; zone.request = function(reqOpts) { assert.deepStrictEqual(reqOpts.json.tags.items, expectedTags); @@ -900,7 +900,7 @@ describe('Zone', function() { }); describe('config.https', function() { - var CONFIG = { + let CONFIG = { https: true, }; @@ -911,7 +911,7 @@ describe('Zone', function() { }); it('should execute cb with error from creating firewall', function(done) { - var error = new Error('Error.'); + let error = new Error('Error.'); zone.createHttpsServerFirewall_ = function(callback) { callback(error); @@ -955,14 +955,14 @@ describe('Zone', function() { }); it('should not overwrite existing tags', function(done) { - var config = { + let config = { https: true, tags: { items: ['a', 'b'], }, }; - var expectedTags = ['a', 'b', 'https-server']; + let expectedTags = ['a', 'b', 'https-server']; zone.request = function(reqOpts) { assert.deepStrictEqual(reqOpts.json.tags.items, expectedTags); @@ -983,7 +983,7 @@ describe('Zone', function() { }); describe('config.os', function() { - var CONFIG = { + let CONFIG = { os: 'os-name', }; @@ -997,7 +997,7 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); + let error = new Error('Error.'); beforeEach(function() { zone.gceImages.getLatest = function(os, callback) { @@ -1014,11 +1014,11 @@ describe('Zone', function() { }); describe('success', function() { - var gceImagesResp = { + let gceImagesResp = { selfLink: 'http://selflink', }; - var expectedConfig = extend({}, EXPECTED_CONFIG, { + let expectedConfig = extend({}, EXPECTED_CONFIG, { disks: [ { autoDelete: true, @@ -1060,8 +1060,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -1081,7 +1081,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = {name: 'operation-name'}; + let apiResponse = {name: 'operation-name'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -1090,8 +1090,8 @@ describe('Zone', function() { }); it('should exec callback with Disk, Op & apiResponse', function(done) { - var vm = {}; - var operation = {}; + let vm = {}; + let operation = {}; zone.vm = function(name) { assert.strictEqual(name, NAME); @@ -1120,10 +1120,10 @@ describe('Zone', function() { }); describe('disk', function() { - var NAME = 'disk-name'; + let NAME = 'disk-name'; it('should return a Disk object', function() { - var disk = zone.disk(NAME); + let disk = zone.disk(NAME); assert(disk instanceof FakeDisk); assert.strictEqual(disk.calledWith_[0], zone); assert.strictEqual(disk.calledWith_[1], NAME); @@ -1141,7 +1141,7 @@ describe('Zone', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; zone.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/autoscalers'); @@ -1154,8 +1154,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -1175,7 +1175,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{name: 'autoscaler-name'}], }; @@ -1186,11 +1186,11 @@ describe('Zone', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -1208,7 +1208,7 @@ describe('Zone', function() { }); it('should execute callback with Autoscalers & API resp', function(done) { - var autoscaler = {}; + let autoscaler = {}; zone.autoscaler = function(name) { assert.strictEqual(name, apiResponse.items[0].name); @@ -1240,7 +1240,7 @@ describe('Zone', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; zone.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/disks'); @@ -1253,8 +1253,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -1274,7 +1274,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{name: 'disk-name'}], }; @@ -1285,11 +1285,11 @@ describe('Zone', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -1307,7 +1307,7 @@ describe('Zone', function() { }); it('should execute callback with Disks & API resp', function(done) { - var disk = {}; + let disk = {}; zone.disk = function(name) { assert.strictEqual(name, apiResponse.items[0].name); @@ -1339,7 +1339,7 @@ describe('Zone', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; zone.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/instanceGroups'); @@ -1352,8 +1352,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -1373,7 +1373,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{name: 'operation-name'}], }; @@ -1384,11 +1384,11 @@ describe('Zone', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -1406,7 +1406,7 @@ describe('Zone', function() { }); it('should execute callback with Groups & API resp', function(done) { - var group = {}; + let group = {}; zone.instanceGroup = function(name) { assert.strictEqual(name, apiResponse.items[0].name); @@ -1429,8 +1429,8 @@ describe('Zone', function() { describe('getMachineTypes', function() { it('should make the correct call to Compute', function(done) { - var options = {a: 'b', c: 'd'}; - var expectedOptions = extend({}, options, { + let options = {a: 'b', c: 'd'}; + let expectedOptions = extend({}, options, { filter: 'zone eq .*' + zone.name, }); @@ -1463,7 +1463,7 @@ describe('Zone', function() { }); it('should return the result of compute.getMachineTypes', function() { - var resultOfGetMachineTypes = {}; + let resultOfGetMachineTypes = {}; zone.compute.getMachineTypes = function() { return resultOfGetMachineTypes; @@ -1484,7 +1484,7 @@ describe('Zone', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; zone.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/operations'); @@ -1497,8 +1497,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -1517,7 +1517,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{name: 'operation-name'}], }; @@ -1528,11 +1528,11 @@ describe('Zone', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -1550,7 +1550,7 @@ describe('Zone', function() { }); it('should execute callback with Operations & API resp', function(done) { - var operation = {}; + let operation = {}; zone.operation = function(name) { assert.strictEqual(name, apiResponse.items[0].name); @@ -1582,7 +1582,7 @@ describe('Zone', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + let query = {a: 'b', c: 'd'}; zone.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/instances'); @@ -1595,8 +1595,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + let error = new Error('Error.'); + let apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -1615,7 +1615,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = { + let apiResponse = { items: [{name: 'vm-name'}], }; @@ -1626,11 +1626,11 @@ describe('Zone', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + let nextPageToken = 'next-page-token'; + let apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + let expectedNextQuery = { pageToken: nextPageToken, }; @@ -1648,7 +1648,7 @@ describe('Zone', function() { }); it('should execute callback with VMs & API response', function(done) { - var vm = {}; + let vm = {}; zone.vm = function(name) { assert.strictEqual(name, apiResponse.items[0].name); @@ -1670,10 +1670,10 @@ describe('Zone', function() { }); describe('instanceGroup', function() { - var NAME = 'instance-group'; + let NAME = 'instance-group'; it('should return an InstanceGroup object', function() { - var instanceGroup = zone.instanceGroup(NAME); + let instanceGroup = zone.instanceGroup(NAME); assert(instanceGroup instanceof FakeInstanceGroup); assert.strictEqual(instanceGroup.calledWith_[0], zone); assert.strictEqual(instanceGroup.calledWith_[1], NAME); @@ -1681,10 +1681,10 @@ describe('Zone', function() { }); describe('machineType', function() { - var NAME = 'machine-name'; + let NAME = 'machine-name'; it('should return a MachineType object', function() { - var machineType = zone.machineType(NAME); + let machineType = zone.machineType(NAME); assert(machineType instanceof FakeMachineType); assert.strictEqual(machineType.calledWith_[0], zone); @@ -1693,10 +1693,10 @@ describe('Zone', function() { }); describe('operation', function() { - var NAME = 'operation-name'; + let NAME = 'operation-name'; it('should return an Operation object', function() { - var operation = zone.operation(NAME); + let operation = zone.operation(NAME); assert(operation instanceof FakeOperation); assert.strictEqual(operation.calledWith_[0], zone); assert.strictEqual(operation.calledWith_[1], NAME); @@ -1704,10 +1704,10 @@ describe('Zone', function() { }); describe('vm', function() { - var NAME = 'vm-name'; + let NAME = 'vm-name'; it('should return a VM object', function() { - var vm = zone.vm(NAME); + let vm = zone.vm(NAME); assert(vm instanceof FakeVM); assert.strictEqual(vm.calledWith_[0], zone); assert.strictEqual(vm.calledWith_[1], NAME); @@ -1733,7 +1733,7 @@ describe('Zone', function() { }); it('should execute callback with error & API response', function(done) { - var error = new Error('Error.'); + let error = new Error('Error.'); zone.compute.createFirewall = function(name, config, callback) { callback(error); @@ -1746,10 +1746,10 @@ describe('Zone', function() { }); it('should not execute callback with error if 409', function(done) { - var error = new Error('Error.'); + let error = new Error('Error.'); error.code = 409; - var apiResponse = {}; + let apiResponse = {}; zone.compute.createFirewall = function(name, config, callback) { callback(error, null, apiResponse); @@ -1781,7 +1781,7 @@ describe('Zone', function() { }); it('should execute callback with error & API response', function(done) { - var error = new Error('Error.'); + let error = new Error('Error.'); zone.compute.createFirewall = function(name, config, callback) { callback(error); @@ -1794,7 +1794,7 @@ describe('Zone', function() { }); it('should not execute callback with error if 409', function(done) { - var error = new Error('Error.'); + let error = new Error('Error.'); error.code = 409; zone.compute.createFirewall = function(name, config, callback) {