Add template tests

This commit is contained in:
Rafal Wilinski 2017-09-13 10:32:26 +02:00
parent f0defb987a
commit 3d1dbd97bd
7 changed files with 39 additions and 7 deletions

View File

@ -39,6 +39,10 @@ services:
image: maven:3-jdk-8
volumes:
- ./tmp/serverless-integration-test-aws-kotlin-jvm-maven:/app
aws-kotlin-node:
image: node:6.10.3
volumes:
- ./tmp/serverless-integration-test-aws-kotlin-node:/app
aws-groovy-gradle:
image: java:8
volumes:

View File

@ -46,6 +46,7 @@ Most commonly used templates:
- aws-python
- aws-python3
- aws-kotlin-jvm-maven
- aws-kotlin-node
- aws-groovy-gradle
- aws-java-maven
- aws-java-gradle

View File

@ -56,6 +56,7 @@ Here are the available runtimes for AWS Lambda:
* aws-python
* aws-python3
* aws-kotlin-jvm-maven
* aws-kotlin-node
* aws-groovy-gradle
* aws-java-gradle
* aws-java-maven

View File

@ -17,6 +17,7 @@ const validTemplates = [
'aws-java-maven',
'aws-java-gradle',
'aws-kotlin-jvm-maven',
'aws-kotlin-node',
'aws-scala-sbt',
'aws-csharp',
'aws-fsharp',

View File

@ -228,6 +228,33 @@ describe('Create', () => {
});
});
it('should generate scaffolding for "aws-kotlin-node" template', () => {
process.chdir(tmpDir);
create.options.template = 'aws-kotlin-node';
return create.create().then(() => {
const dirContent = walkDirSync(tmpDir)
.map(elem => elem.replace(path.join(tmpDir, path.sep), ''));
expect(dirContent).to.include('serverless.yml');
expect(dirContent).to.include('build.gradle');
expect(dirContent).to.include('gradlew');
expect(dirContent).to.include('gradlew.bat');
expect(dirContent).to.include(path.join('gradle', 'wrapper',
'gradle-wrapper.jar'));
expect(dirContent).to.include(path.join('gradle', 'wrapper',
'gradle-wrapper.properties'));
expect(dirContent).to.include(path.join('src', 'main', 'kotlin', 'com', 'serverless',
'Handler.kt'));
expect(dirContent).to.include(path.join('src', 'main', 'kotlin', 'com', 'serverless',
'ApiGatewayResponse.kt'));
expect(dirContent).to.include(path.join('src', 'main', 'kotlin', 'com', 'serverless',
'Response.kt'));
expect(dirContent).to.include(path.join('src', 'test', 'kotlin', '.gitkeep'));
expect(dirContent).to.include(path.join('.gitignore'));
});
});
it('should generate scaffolding for "aws-java-gradle" template', () => {
process.chdir(tmpDir);
create.options.template = 'aws-java-gradle';

View File

@ -28,13 +28,10 @@ class ApiGatewayResponse(
fun build(): ApiGatewayResponse {
var body: String? = null
if (rawBody != null) {
body = rawBody as String
}
else if (objectBody != null) {
body = objectBody.toString()
} else if (binaryBody != null) {
body = binaryBody.toString()
when {
rawBody != null -> body = rawBody as String
objectBody != null -> body = objectBody.toString()
binaryBody != null -> body = binaryBody.toString()
}
return ApiGatewayResponse(statusCode, body, headers, base64Encoded)

View File

@ -18,6 +18,7 @@ integration-test aws-nodejs
integration-test aws-python
integration-test aws-python3
integration-test aws-kotlin-jvm-maven
integration-test aws-kotlin-node
integration-test aws-nodejs-typescript
integration-test aws-nodejs-ecma-script
integration-test google-nodejs