Skip to content

Commit f766ee6

Browse files
committed
fix: update remove flow
1 parent 59c0039 commit f766ee6

File tree

10 files changed

+30
-42
lines changed

10 files changed

+30
-42
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ jobs:
4343
env:
4444
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
4545
GIT_AUTHOR_NAME: slsplus
46-
GIT_AUTHOR_EMAIL: yuga.sun.bj@gmail.com
46+
GIT_AUTHOR_EMAIL: slsplus.sz@gmail.com
4747
GIT_COMMITTER_NAME: slsplus
48-
GIT_COMMITTER_EMAIL: yuga.sun.bj@gmail.com
48+
GIT_COMMITTER_EMAIL: slsplus.sz@gmail.com

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: |
3939
npm update --no-save
4040
npm update --save-dev --no-save
41-
- name: Running integration tests
41+
- name: Running tests
4242
run: npm run test
4343
env:
4444
TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }}
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
require('dotenv').config()
2-
const { generateId, getServerlessSdk } = require('./utils')
1+
const { join } = require('path');
2+
require('dotenv').config({ path: join(__dirname, '.env.test') });
3+
4+
const { generateId, getServerlessSdk } = require('./lib/utils')
35
const execSync = require('child_process').execSync
46
const path = require('path')
57
const axios = require('axios')
68

7-
// set enough timeout for deployment to finish
8-
jest.setTimeout(300000)
9-
10-
// the yaml file we're testing against
119
const instanceYaml = {
1210
org: 'orgDemo',
1311
app: 'appDemo',
14-
component: 'express',
12+
component: 'express@dev',
1513
name: `express-integration-tests-${generateId()}`,
1614
stage: 'dev',
1715
inputs: {
@@ -28,15 +26,13 @@ const credentials = {
2826
}
2927
}
3028

31-
// get serverless construct sdk
3229
const sdk = getServerlessSdk(instanceYaml.org)
3330

3431
it('should successfully deploy express app', async () => {
3532
const instance = await sdk.deploy(instanceYaml, credentials)
3633

3734
expect(instance).toBeDefined()
3835
expect(instance.instanceName).toEqual(instanceYaml.name)
39-
// get src from template by default
4036
expect(instance.outputs.templateUrl).toBeDefined()
4137
expect(instance.outputs.region).toEqual(instanceYaml.inputs.region)
4238
expect(instance.outputs.apigw).toBeDefined()
@@ -47,14 +43,14 @@ it('should successfully deploy express app', async () => {
4743

4844
it('should successfully update source code', async () => {
4945
// change source to own source './src' and need to install packages before deploy
50-
const srcPath = path.join(__dirname, 'src')
46+
const srcPath = path.join(__dirname, '..', 'example')
5147
execSync('npm install', { cwd: srcPath })
5248
instanceYaml.inputs.src = srcPath
5349

5450
const instance = await sdk.deploy(instanceYaml, credentials)
5551
const response = await axios.get(instance.outputs.apigw.url)
5652

57-
expect(response.data).toEqual('hello world')
53+
expect(response.data.includes('Serverless Framework')).toBeTruthy()
5854
expect(instance.outputs.templateUrl).not.toBeDefined()
5955
})
6056

File renamed without changes.

jest.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const { join } = require('path')
2+
require('dotenv').config({ path: join(__dirname, '.env.test') })
3+
4+
const config = {
5+
verbose: true,
6+
silent: false,
7+
testTimeout: 600000,
8+
testEnvironment: 'node',
9+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$',
10+
testPathIgnorePatterns: ['/node_modules/', '/__tests__/lib/'],
11+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
12+
}
13+
14+
module.exports = config

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"access": "public"
66
},
77
"scripts": {
8-
"test": "jest ./tests/integration.test.js --testEnvironment node",
8+
"test": "jest",
99
"commitlint": "commitlint -f HEAD@{15}",
1010
"lint": "eslint --ext .js,.ts,.tsx .",
1111
"lint:fix": "eslint --fix --ext .js,.ts,.tsx .",

serverless.component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: express
2-
version: 0.2.1
2+
version: 0.2.2
33
author: Tencent Cloud, Inc.
44
org: Tencent Cloud, Inc.
55
description: Deploy a serverless Express.js application on Tencent SCF and API Gateway.

src/serverless.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ class ServerlessComponent extends Component {
247247
const scf = new Scf(credentials, curRegion)
248248
const apigw = new Apigw(credentials, curRegion)
249249
const handler = async () => {
250-
await scf.remove({
251-
functionName: curState.functionName,
252-
namespace: curState.namespace
253-
})
254250
// if disable apigw, no need to remove
255251
if (state.apigwDisabled !== true) {
256252
await apigw.remove({
@@ -261,6 +257,10 @@ class ServerlessComponent extends Component {
261257
customDomains: curState.customDomains
262258
})
263259
}
260+
await scf.remove({
261+
functionName: curState.functionName,
262+
namespace: curState.namespace
263+
})
264264
}
265265
removeHandlers.push(handler())
266266
}

tests/src/package.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/src/sls.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)