fix tests

This commit is contained in:
Egor Kislitsyn 2016-02-18 18:53:58 +07:00
parent a60d8c140b
commit 98d22f9fa6
6 changed files with 35 additions and 22 deletions

View File

@ -88,7 +88,7 @@ let cleanup = function(Meta, cb, evt) {
// Delete CloudFormation Resources Stack
let cloudformation = new AWS.CloudFormation();
cloudformation.deleteStack({
StackName: Meta.stages[config.stage].regions[config.region].variables.resourcesStackName
StackName: serverless.getProject().getRegion(config.stage, config.region)._variables.resourcesStackName
}, function (err, data) {
if (err) console.log(err, err.stack); // an error occurred
@ -140,14 +140,17 @@ describe('Test action: Project Init', function() {
// Validate Meta
let Meta = serverless.state.getMeta();
let stage = serverless.getProject().getStage(config.stage);
let region = serverless.getProject().getRegion(config.stage, config.region);
assert.equal(true, typeof Meta.variables.project != 'undefined');
assert.equal(true, typeof Meta.variables.domain != 'undefined');
assert.equal(true, typeof Meta.variables.projectBucket != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage].variables.stage != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region].variables.region != 'undefined');
assert.equal(true, typeof stage._variables.stage != 'undefined');
assert.equal(true, typeof region._variables.region != 'undefined');
if (!config.noExecuteCf) {
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region].variables.iamRoleArnLambda != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region].variables.resourcesStackName != 'undefined');
assert.equal(true, typeof region._variables.iamRoleArnLambda != 'undefined');
assert.equal(true, typeof region._variables.resourcesStackName != 'undefined');
}
// Validate Event

View File

@ -140,15 +140,18 @@ describe('Test action: Project Install', function() {
// Validate Meta
let Meta = serverless.state.getMeta();
let stage = serverless.getProject().getStage(config.stage);
let region = serverless.getProject().getRegion(config.stage, config.region);
assert.equal(true, typeof Meta.variables.project != 'undefined');
assert.equal(true, typeof Meta.variables.domain != 'undefined');
assert.equal(true, typeof Meta.variables.projectBucket != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage].variables.stage != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region].variables.region != 'undefined');
assert.equal(true, typeof stage._variables.stage != 'undefined');
assert.equal(true, typeof region._variables.region != 'undefined');
if (!config.noExecuteCf) {
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region].variables.iamRoleArnLambda != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region].variables.resourcesStackName != 'undefined');
assert.equal(true, typeof region._variables.iamRoleArnLambda != 'undefined');
assert.equal(true, typeof region._variables.resourcesStackName != 'undefined');
}
// Validate Event

View File

@ -105,7 +105,8 @@ describe('Test Action: Region Create', function() {
let Meta = serverless.state.meta;
//console.log(serverless.state.meta.stages)
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region2].variables.region != 'undefined');
assert.equal(true, typeof serverless.getProject().getRegion(config.stage, config.region2)._variables.region != 'undefined');
// Validate Event
validateEvent(evt);

View File

@ -97,8 +97,9 @@ describe('Test Action: Stage Create', function() {
.then(function(evt) {
let Meta = serverless.state.meta;
assert.equal(true, typeof Meta.stages[config.stage2].variables.stage != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage2].regions[config.region].variables.region != 'undefined');
let project = serverless.getProject();
assert.equal(true, typeof project.getStage(config.stage2)._variables.stage != 'undefined');
assert.equal(true, typeof project.getRegion(config.stage2, config.region)._variables.region != 'undefined');
// Validate EVT
validateEvent(evt);

View File

@ -116,14 +116,18 @@ describe('Test: Project Live Cycle', function() {
// Validate Meta
let Meta = serverless.state.getMeta();
let stage = serverless.getProject().getStage(config.stage);
let region = serverless.getProject().getRegion(config.stage, config.region);
assert.equal(true, typeof Meta.variables.project != 'undefined');
assert.equal(true, typeof Meta.variables.domain != 'undefined');
assert.equal(true, typeof Meta.variables.projectBucket != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage].variables.stage != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region].variables.region != 'undefined');
assert.equal(true, typeof stage._variables.stage != 'undefined');
assert.equal(true, typeof region._variables.region != 'undefined');
if (!config.noExecuteCf) {
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region].variables.iamRoleArnLambda != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage].regions[config.region].variables.resourcesStackName != 'undefined');
assert.equal(true, typeof region._variables.iamRoleArnLambda != 'undefined');
assert.equal(true, typeof region._variables.resourcesStackName != 'undefined');
}
// Validate Event
@ -156,8 +160,11 @@ describe('Test: Project Live Cycle', function() {
.then(function(evt) {
let Meta = serverless.state.meta;
assert.equal(true, typeof Meta.stages[config.stage2].variables.stage != 'undefined');
assert.equal(true, typeof Meta.stages[config.stage2].regions[config.region].variables.region != 'undefined');
let stage = serverless.getProject().getStage(config.stage2);
let region = serverless.getProject().getRegion(config.stage2, config.region);
assert.equal(true, typeof stage._variables.stage != 'undefined');
assert.equal(true, typeof region._variables.region != 'undefined');
// Validate EVT
validateEvent(evt);
@ -188,8 +195,7 @@ describe('Test: Project Live Cycle', function() {
return serverless.actions.regionCreate(evt)
.then(function(evt) {
let Meta = serverless.state.meta;
assert.equal(true, typeof Meta.stages[config.stage2].regions[config.region2].variables.region != 'undefined');
assert.equal(true, typeof serverless.getProject().getRegion(config.stage2, config.region2)._variables.region != 'undefined');
// Validate Event
validateEvent(evt);

View File

@ -31,7 +31,6 @@ describe('Test Serverless Project Class', function() {
return serverless.init()
.then(function() {
// Instantiate Class
instance = serverless.getProject();
@ -78,7 +77,7 @@ describe('Test Serverless Project Class', function() {
// These functions have their own s-templates.json files which give them the same template, with one different property
// Function1 template
assert.equal(true, data.components.nodejscomponent.functions['nodejscomponent/group1/function1'].endpoints[0].requestTemplates['application/json'].pathParams === "$input.path('$.id1')");
assert.equal(data.components.nodejscomponent.functions['nodejscomponent/group1/function1'].endpoints[0].requestTemplates['application/json'].pathParams, "$input.path('$.id1')");
// Function2 template
assert.equal(true, data.components.nodejscomponent.functions['nodejscomponent/group1/function2'].endpoints[0].requestTemplates['application/json'].pathParams === "$input.path('$.id2')");
// Function3 template - s-templates.json left undefined