mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
75 lines
1.6 KiB
JavaScript
75 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Test: Function Run Action
|
|
*/
|
|
|
|
let Serverless = require('../../../lib/Serverless.js'),
|
|
path = require('path'),
|
|
utils = require('../../../lib/utils/index'),
|
|
assert = require('chai').assert,
|
|
testUtils = require('../../test_utils'),
|
|
config = require('../../config');
|
|
|
|
let serverless;
|
|
|
|
/**
|
|
* Validate Event
|
|
* - Validate an event object's properties
|
|
*/
|
|
|
|
let validateEvent = function(evt) {
|
|
assert.equal(true, typeof evt.options.path != 'undefined');
|
|
assert.equal(true, typeof evt.data.result != 'undefined');
|
|
assert.equal(true, evt.data.result.status === 'success');
|
|
};
|
|
|
|
describe('Test Action: Function Run', function() {
|
|
|
|
before(function(done) {
|
|
this.timeout(0);
|
|
|
|
testUtils.createTestProject(config, ['nodejscomponent'])
|
|
.then(projPath => {
|
|
|
|
this.timeout(0);
|
|
|
|
process.chdir(projPath);
|
|
|
|
serverless = new Serverless({
|
|
interactive: true,
|
|
awsAdminKeyId: config.awsAdminKeyId,
|
|
awsAdminSecretKey: config.awsAdminSecretKey,
|
|
projectPath: projPath
|
|
});
|
|
|
|
done();
|
|
});
|
|
});
|
|
|
|
after(function(done) {
|
|
done();
|
|
});
|
|
|
|
describe('Function Run w/ Path', function() {
|
|
it('should run the function with no errors', function(done) {
|
|
|
|
this.timeout(0);
|
|
let options = {
|
|
path: 'nodejscomponent/module1/function1'
|
|
};
|
|
|
|
serverless.actions.functionRun(options)
|
|
.then(function(evt) {
|
|
validateEvent(evt);
|
|
|
|
done();
|
|
})
|
|
.catch(e => {
|
|
done(e);
|
|
});
|
|
});
|
|
});
|
|
|
|
});
|