Skip to content

Commit

Permalink
chore: prettify cucumber tests (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Jan 10, 2020
1 parent c589722 commit 5881e45
Show file tree
Hide file tree
Showing 73 changed files with 2,006 additions and 1,252 deletions.
4 changes: 2 additions & 2 deletions features/acm/step_definitions/acm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var { ACM } = require('../../../clients/node/client-acm-node');
var { ACM } = require("../../../clients/node/client-acm-node");

module.exports = function() {
this.Before("@acm", function (callback) {
this.Before("@acm", function(callback) {
this.service = new ACM({});
callback();
});
Expand Down
2 changes: 1 addition & 1 deletion features/apigateway/step_definitions/apigateway.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = function() {
this.Before("@apigateway", function (callback) {
this.Before("@apigateway", function(callback) {
this.service = new this.AWS.APIGateway();
callback();
});
Expand Down
45 changes: 28 additions & 17 deletions features/autoscaling/step_definitions/autoscaling.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
var { AutoScaling } = require('../../../clients/node/client-auto-scaling-node');
var { AutoScaling } = require("../../../clients/node/client-auto-scaling-node");

module.exports = function() {
this.Before('@autoscaling', function (callback) {
this.service = new AutoScaling({region: 'us-east-1'});
this.Before("@autoscaling", function(callback) {
this.service = new AutoScaling({ region: "us-east-1" });
callback();
});

this.Given(/^I create a launch configuration with name "([^"]*)"$/, function(name, callback) {
this.Given(/^I create a launch configuration with name "([^"]*)"$/, function(
name,
callback
) {
var params = {
ImageId: 'ami-1624987f',
InstanceType: 'm1.small',
ImageId: "ami-1624987f",
InstanceType: "m1.small",
LaunchConfigurationName: name
};
this.request(null, 'createLaunchConfiguration', params, callback, false);
this.request(null, "createLaunchConfiguration", params, callback, false);
});

this.Given(/^I describe launch configurations$/, function(callback) {
this.request(null, 'describeLaunchConfigurations', {}, callback);
this.request(null, "describeLaunchConfigurations", {}, callback);
});

this.Then(/^the list should contain the launch configuration "([^"]*)"$/, function(name, callback) {
this.assert.contains(this.data.LaunchConfigurations, function(configuration) {
return configuration.LaunchConfigurationName === name;
});
callback();
});
this.Then(
/^the list should contain the launch configuration "([^"]*)"$/,
function(name, callback) {
this.assert.contains(this.data.LaunchConfigurations, function(
configuration
) {
return configuration.LaunchConfigurationName === name;
});
callback();
}
);

this.Then(/^I delete the launch configuration "([^"]*)"$/, function(name, callback) {
var params = {LaunchConfigurationName: name};
this.request(null, 'deleteLaunchConfiguration', params, callback);
this.Then(/^I delete the launch configuration "([^"]*)"$/, function(
name,
callback
) {
var params = { LaunchConfigurationName: name };
this.request(null, "deleteLaunchConfiguration", params, callback);
});
};
24 changes: 16 additions & 8 deletions features/cloudformation/step_definitions/cloudformation.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
var { CloudFormation } = require('../../../clients/node/client-cloudformation-node');
var {
CloudFormation
} = require("../../../clients/node/client-cloudformation-node");

module.exports = function() {
this.Before("@cloudformation", function (callback) {
this.Before("@cloudformation", function(callback) {
this.service = new CloudFormation({});
callback();
});

this.Given(/^I create a CloudFormation stack with name prefix "([^"]*)"$/, function(prefix, callback) {
this.stackName = this.uniqueName(prefix);
this.templateBody = '{"Resources":{"member":{"Type":"AWS::SQS::Queue"}}}';
var params = { TemplateBody: this.templateBody, StackName: this.stackName };
this.request(null, 'createStack', params, callback, false);
});
this.Given(
/^I create a CloudFormation stack with name prefix "([^"]*)"$/,
function(prefix, callback) {
this.stackName = this.uniqueName(prefix);
this.templateBody = '{"Resources":{"member":{"Type":"AWS::SQS::Queue"}}}';
var params = {
TemplateBody: this.templateBody,
StackName: this.stackName
};
this.request(null, "createStack", params, callback, false);
}
);
};
38 changes: 20 additions & 18 deletions features/cloudfront/step_definitions/cloudfront-latest.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
module.exports = function() {
var createParams = {
CallerReference: '',
CallerReference: "",
Aliases: {
Quantity: 0
},
DefaultRootObject: '',
DefaultRootObject: "",
Origins: {
Items: [{
Id: 'origin',
DomainName: 'example.com',
CustomOriginConfig: {
HTTPPort: 80,
HTTPSPort: 443,
OriginProtocolPolicy: 'match-viewer'
Items: [
{
Id: "origin",
DomainName: "example.com",
CustomOriginConfig: {
HTTPPort: 80,
HTTPSPort: 443,
OriginProtocolPolicy: "match-viewer"
}
}
}],
],
Quantity: 1
},
DefaultCacheBehavior: {
TargetOriginId: 'origin',
TargetOriginId: "origin",
ForwardedValues: {
QueryString: false,
Cookies: { Forward: 'all' }
Cookies: { Forward: "all" }
},
TrustedSigners: {
Items: [],
Enabled: false,
Quantity: 0
},
ViewerProtocolPolicy: 'allow-all',
ViewerProtocolPolicy: "allow-all",
MinTTL: 0
},
CacheBehaviors: {
Items: [],
Quantity: 0
},
Comment: '',
Comment: "",
Logging: {
Enabled: false,
Bucket: 'invalidbucket.s3.amazonaws.com',
Prefix: 'prefix',
Bucket: "invalidbucket.s3.amazonaws.com",
Prefix: "prefix",
IncludeCookies: false
},
PriceClass: 'PriceClass_All',
PriceClass: "PriceClass_All",
Enabled: false
};

this.Before("@cloudfront", function (callback) {
this.Before("@cloudfront", function(callback) {
this.service = new this.AWS.CloudFront();
this.cfCreateParams = createParams;
callback();
Expand Down
25 changes: 17 additions & 8 deletions features/cloudfront/step_definitions/cloudfront.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
module.exports = function() {
this.Given(/^I create a CloudFront distribution with name prefix "([^"]*)"$/, function(prefix, callback) {
this.cfName = this.uniqueName(prefix);
this.cfCreateParams.CallerReference = this.cfName;
this.cfCreateParams.Origins.Items[0].Id = (this.cfName === '' ? 'origin' : 'InvalidOrigin');
this.request(null, 'createDistribution', { DistributionConfig: this.cfCreateParams }, callback, false);
});
this.Given(
/^I create a CloudFront distribution with name prefix "([^"]*)"$/,
function(prefix, callback) {
this.cfName = this.uniqueName(prefix);
this.cfCreateParams.CallerReference = this.cfName;
this.cfCreateParams.Origins.Items[0].Id =
this.cfName === "" ? "origin" : "InvalidOrigin";
this.request(
null,
"createDistribution",
{ DistributionConfig: this.cfCreateParams },
callback,
false
);
}
);

this.Given(/^I list CloudFront distributions$/, function(callback) {
this.request(null, 'listDistributions', {}, callback);
this.request(null, "listDistributions", {}, callback);
});

};
17 changes: 13 additions & 4 deletions features/cloudsearch/step_definitions/cloudsearch.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
var { CloudSearch } = require('../../../clients/node/client-cloudsearch-node');
var { CloudSearch } = require("../../../clients/node/client-cloudsearch-node");

module.exports = function() {
this.Before("@cloudsearch", function (callback) {
this.Before("@cloudsearch", function(callback) {
this.service = new CloudSearch({});
callback();
});

this.Given(/^I create a domain with name prefix "([^"]*)"$/, function(prefix, callback) {
this.Given(/^I create a domain with name prefix "([^"]*)"$/, function(
prefix,
callback
) {
this.domainName = this.uniqueName(prefix);
this.request(null, 'createDomain', {DomainName: this.domainName}, callback, false);
this.request(
null,
"createDomain",
{ DomainName: this.domainName },
callback,
false
);
});
};
14 changes: 10 additions & 4 deletions features/cloudtrail/step_definitions/cloudtrail.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
var { CloudTrail } = require('../../../clients/node/client-cloudtrail-node');
var { CloudTrail } = require("../../../clients/node/client-cloudtrail-node");

module.exports = function() {
this.Before("@cloudtrail", function (callback) {
this.Before("@cloudtrail", function(callback) {
this.service = new CloudTrail({});
callback();
});

this.Given(/^I describe trails$/, function(callback) {
this.request(null, 'describeTrails', {}, callback);
this.request(null, "describeTrails", {}, callback);
});

this.Given(/^I create a trail with an invalid name$/, function(callback) {
this.request(null, 'createTrail', {Name: '', S3BucketName: ''}, callback, false);
this.request(
null,
"createTrail",
{ Name: "", S3BucketName: "" },
callback,
false
);
});
};
62 changes: 38 additions & 24 deletions features/cloudwatch/step_definitions/cloudwatch.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
var { CloudWatch } = require('../../../clients/node/client-cloudwatch-node');
var { CloudWatch } = require("../../../clients/node/client-cloudwatch-node");

module.exports = function() {
this.Before("@cloudwatch", function (callback) {
this.Before("@cloudwatch", function(callback) {
this.service = new CloudWatch({});
callback();
});

this.Given(/^I create a CloudWatch alarm with (prefix|name) "([^"]*)"$/, function(prefix, name, callback) {
var timestamp = new Date().getTime();
this.cloudWatchAlarm = {
AlarmName: name,
MetricName: 'aws-sdk-js-metric-' + timestamp,
Namespace: 'aws-sdk-js-namespace' + timestamp,
ComparisonOperator: 'GreaterThanThreshold',
EvaluationPeriods: 5,
Period: 60,
Statistic: 'Average',
Threshold: 50.0
};
this.Given(
/^I create a CloudWatch alarm with (prefix|name) "([^"]*)"$/,
function(prefix, name, callback) {
var timestamp = new Date().getTime();
this.cloudWatchAlarm = {
AlarmName: name,
MetricName: "aws-sdk-js-metric-" + timestamp,
Namespace: "aws-sdk-js-namespace" + timestamp,
ComparisonOperator: "GreaterThanThreshold",
EvaluationPeriods: 5,
Period: 60,
Statistic: "Average",
Threshold: 50.0
};

if (prefix === 'prefix') {
this.cloudWatchAlarm.AlarmName += '-' + timestamp;
}
if (prefix === "prefix") {
this.cloudWatchAlarm.AlarmName += "-" + timestamp;
}

this.request(null, 'putMetricAlarm', this.cloudWatchAlarm,
callback, prefix === 'name' ? false : undefined);
});
this.request(
null,
"putMetricAlarm",
this.cloudWatchAlarm,
callback,
prefix === "name" ? false : undefined
);
}
);

this.Given(/^I list the CloudWatch alarms$/, function(callback) {
var params = {
MetricName: this.cloudWatchAlarm.MetricName,
Namespace: this.cloudWatchAlarm.Namespace
};
this.request(null, 'describeAlarmsForMetric', params, callback);
this.request(null, "describeAlarmsForMetric", params, callback);
});

this.Then(/^the list should contain the CloudWatch alarm$/, function(callback) {
this.Then(/^the list should contain the CloudWatch alarm$/, function(
callback
) {
var name = this.cloudWatchAlarm.AlarmName;
this.assert.contains(this.data.MetricAlarms, function(alarm) {
return alarm.AlarmName === name;
Expand All @@ -44,7 +54,11 @@ module.exports = function() {
});

this.Then(/^I delete the CloudWatch alarm$/, function(callback) {
this.request(null, 'deleteAlarms',
{AlarmNames: [this.cloudWatchAlarm.AlarmName]}, callback);
this.request(
null,
"deleteAlarms",
{ AlarmNames: [this.cloudWatchAlarm.AlarmName] },
callback
);
});
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var { CloudWatchEvents } = require('../../../clients/node/client-cloudwatch-events-node');
var {
CloudWatchEvents
} = require("../../../clients/node/client-cloudwatch-events-node");

module.exports = function() {
this.Before("@cloudwatchevents", function (callback) {
this.Before("@cloudwatchevents", function(callback) {
this.service = new CloudWatchEvents({});
callback();
});
Expand Down
Loading

0 comments on commit 5881e45

Please sign in to comment.