Skip to content

Commit bae939c

Browse files
committed
add setup ci/cd
1 parent 52df11f commit bae939c

File tree

6 files changed

+2996
-4448
lines changed

6 files changed

+2996
-4448
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ lib-cov
1313

1414
# Coverage directory used by tools like istanbul
1515
coverage
16+
.nyc_output
1617

1718
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
1819
.grunt

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: node_js
2+
3+
matrix:
4+
include:
5+
- node_js: '8.9'
6+
- node_js: '10.6'
7+
- node_js: '10.6'
8+
env:
9+
- DISABLE_TESTS=true
10+
- LINTING=true
11+
12+
sudo: false
13+
14+
install:
15+
- travis_retry npm install
16+
17+
script:
18+
- if [[ -z "$DISABLE_TESTS" ]]; then npm run test; fi
19+
- if [[ ! -z "$DISABLE_TESTS" && ! -z "$LINTING" ]]; then npm run lint; fi
20+
21+
after_success:
22+
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage

lib/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,17 @@ class ServerlessApigatewayServiceProxy {
8787
] == 'AWS::ApiGateway::Deployment'
8888
) {
8989
exists = true
90-
this.serverless.service.provider.compiledCloudFormationTemplate.Resources[resource]['DependsOn'] = this.serverless.service.provider.compiledCloudFormationTemplate.Resources[resource]['DependsOn'].concat(this.apiGatewayMethodLogicalIds)
90+
this.serverless.service.provider.compiledCloudFormationTemplate.Resources[resource][
91+
'DependsOn'
92+
] = this.serverless.service.provider.compiledCloudFormationTemplate.Resources[resource][
93+
'DependsOn'
94+
].concat(this.apiGatewayMethodLogicalIds)
9195
}
9296
}
9397
)
9498

9599
if (!exists) {
96-
await this.compileDeployment()
100+
await this.compileDeployment()
97101
}
98102
}
99103

lib/utils.test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
'use strict'
2+
3+
const expect = require('chai').expect
4+
//const BbPromise = require('bluebird')
5+
const Serverless = require('serverless/lib/Serverless')
6+
const AwsProvider = require('serverless/lib/plugins/aws/provider/awsProvider')
7+
const ServerlessApigatewayServiceProxy = require('./index')
8+
9+
describe('#getAllServiceProxies()', () => {
10+
let serverless
11+
let serverlessApigatewayServiceProxy
12+
13+
beforeEach(() => {
14+
serverless = new Serverless()
15+
serverless.servicePath = true
16+
serverless.service.service = 'apigw-service-proxy'
17+
const options = {
18+
stage: 'dev',
19+
region: 'us-east-1'
20+
}
21+
serverless.setProvider('aws', new AwsProvider(serverless))
22+
serverlessApigatewayServiceProxy = new ServerlessApigatewayServiceProxy(serverless, options)
23+
})
24+
25+
it('should return this plugin configutration', () => {
26+
serverless.service.custom = {
27+
apiGatewayServiceProxies: [
28+
{
29+
kinesis: {
30+
path: '/kinesis',
31+
method: 'post'
32+
}
33+
}
34+
]
35+
}
36+
37+
expect(serverlessApigatewayServiceProxy.getAllServiceProxies()).to.deep.equal([
38+
{
39+
kinesis: {
40+
path: '/kinesis',
41+
method: 'post'
42+
}
43+
}
44+
])
45+
})
46+
47+
it('should return empty if no configuration', () => {
48+
expect(serverlessApigatewayServiceProxy.getAllServiceProxies()).to.be.empty
49+
})
50+
})

0 commit comments

Comments
 (0)