UNPKG

2.9 kBJavaScriptView Raw
1var utils = require('./utils')
2var backbeam = utils.backbeam()
3var assert = require('assert')
4
5require('./aws-mock')
6
7describe('Lambda methods', () => {
8
9 before(() => utils.init())
10
11 it('#lambdaCreateFunction', () => {
12 var params = {
13 functionName: 'testFunction',
14 filename: 'functions/testFunction.js',
15 handler: 'run',
16 role: 'arn:aws:iam::551937714682:role/lambda_dynamo',
17 memory: 128,
18 timeout: 3
19 }
20 return backbeam.lambdaCreateFunction(params)
21 .then(() => backbeam.readConfig())
22 .then((data) => {
23 var func = backbeam._findFunction(data, params)
24 assert.deepEqual(func, {
25 "functionName": "testFunction",
26 "filename": "functions/testFunction.js",
27 "handler": "run",
28 "role": "arn:aws:iam::551937714682:role/lambda_dynamo",
29 "memory": 128,
30 "timeout": 3
31 })
32 })
33 })
34
35 it('#lambdaEditFunction', () => {
36 var params = {
37 functionName: 'testFunction',
38 filename: 'functions/testFunction.js',
39 handler: 'run',
40 role: 'arn:aws:iam::551937714682:role/lambda_dynamo',
41 memory: 256,
42 timeout: 3
43 }
44 return backbeam.lambdaEditFunction(params)
45 .then(() => backbeam.readConfig())
46 .then((data) => {
47 var func = backbeam._findFunction(data, params)
48 assert.deepEqual(func, {
49 "functionName": "testFunction",
50 "filename": "functions/testFunction.js",
51 "handler": "run",
52 "role": "arn:aws:iam::551937714682:role/lambda_dynamo",
53 "memory": 256,
54 "timeout": 3
55 })
56 })
57 })
58
59 it('#lambdaSyncFunction', () => {
60 return backbeam.lambdaSyncFunction('testFunction')
61 .then(() => backbeam.readConfig())
62 .then((data) => {
63 var func = backbeam._findFunction(data, { functionName: 'testFunction' })
64 assert.ok(func)
65 assert.ok(func.hash)
66 assert.ok(func.functionArn)
67 })
68 })
69
70 it('#lambdaSyncFunction updating an existing one', () => {
71 return backbeam.lambdaSyncFunction('testFunction')
72 .then(() => backbeam.readConfig())
73 .then((data) => {
74 var func = backbeam._findFunction(data, { functionName: 'testFunction' })
75 assert.ok(func)
76 assert.ok(func.hash)
77 assert.ok(func.functionArn)
78 })
79 })
80
81 it('Lambda and API integration', () => {
82 var params = {
83 method: 'PUT',
84 path: '/test',
85 functionName: 'testFunction',
86 }
87 return backbeam.apiCreateEndpoint(params)
88 .then(() => backbeam.apiSyncEndpoint(params))
89 })
90
91 it('Lambda and API integration with HTML', () => {
92 var params = {
93 method: 'POST',
94 path: '/test',
95 functionName: 'testFunction',
96 input: 'html',
97 output: 'html',
98 }
99 return backbeam.apiCreateEndpoint(params)
100 .then(() => backbeam.apiSyncEndpoint(params))
101 })
102
103})