Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2738f7
commit 0d77c92
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
service: uncategorized-tests | ||
|
||
provider: | ||
name: aws | ||
stage: dev | ||
region: us-east-1 # default | ||
runtime: nodejs10.x | ||
memorySize: 128 | ||
versionFunctions: false | ||
|
||
plugins: | ||
- './../../../index' | ||
|
||
functions: | ||
# https://github.com/serverless/serverless/issues/4218#issue-255617750 | ||
# bug? | ||
# - ${file(./handlerPayload.yml)} | ||
|
||
uncategorizedHandler1: | ||
events: | ||
- http: | ||
integration: lambda | ||
method: get | ||
path: uncategorized-1 | ||
responses: | ||
default: | ||
responseModels: | ||
application/json;charset=UTF-8: Empty | ||
responseParameters: | ||
method.response.header.x-foo: 'integration.response.body.foo' | ||
responseTemplates: | ||
application/json;charset=UTF-8: '' | ||
statusCode: 200 | ||
handler: uncategorized.uncategorizedHandler1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
module.exports.uncategorizedHandler1 = async () => { | ||
return { | ||
foo: 'bar', | ||
}; | ||
}; |
39 changes: 39 additions & 0 deletions
39
src/__tests__/integration/uncategorized/uncategorized.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
const { resolve } = require('path'); | ||
const { URL } = require('url'); | ||
const fetch = require('node-fetch'); | ||
const Serverless = require('serverless'); | ||
const ServerlessOffline = require('../../../../src/ServerlessOffline.js'); | ||
|
||
jest.setTimeout(30000); | ||
|
||
describe('handler payload tests', () => { | ||
let serverlessOffline; | ||
|
||
// init | ||
beforeAll(async () => { | ||
const serverless = new Serverless(); | ||
serverless.config.servicePath = resolve(__dirname); | ||
await serverless.init(); | ||
serverlessOffline = new ServerlessOffline(serverless, {}); | ||
|
||
return serverlessOffline.start(); | ||
}); | ||
|
||
// cleanup | ||
afterAll(async () => { | ||
return serverlessOffline.end(); | ||
}); | ||
|
||
const url = new URL('http://localhost:3000'); | ||
|
||
// issue: https://github.com/dherault/serverless-offline/issues/756 | ||
// PR: https://github.com/dherault/serverless-offline/pull/757 | ||
test('Uncategorized 1', async () => { | ||
url.pathname = 'uncategorized-1'; | ||
const response = await fetch(url); | ||
const json = await response.json(); | ||
expect(json).toEqual({ foo: 'bar' }); | ||
}); | ||
}); |