|
| 1 | +const { generateId, getServerlessSdk } = require('./utils') |
| 2 | + |
| 3 | +// set enough timeout for deployment to finish |
| 4 | +jest.setTimeout(300000) |
| 5 | + |
| 6 | +// the yaml file we're testing against |
| 7 | +const instanceYaml = { |
| 8 | + org: 'orgDemo', |
| 9 | + app: 'appDemo', |
| 10 | + component: 'flask@dev', |
| 11 | + name: `flask-integration-tests-${generateId()}`, |
| 12 | + stage: 'dev', |
| 13 | + inputs: { |
| 14 | + runtime: 'Python3.6', |
| 15 | + region: 'ap-guangzhou', |
| 16 | + apigatewayConf: { environment: 'test' } |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +// get credentials from process.env but need to init empty credentials object |
| 21 | +const credentials = { |
| 22 | + tencent: {} |
| 23 | +} |
| 24 | + |
| 25 | +// get serverless construct sdk |
| 26 | +const sdk = getServerlessSdk(instanceYaml.org) |
| 27 | + |
| 28 | +it('should successfully deploy flask app', async () => { |
| 29 | + const instance = await sdk.deploy(instanceYaml, { tencent: {} }) |
| 30 | + expect(instance).toBeDefined() |
| 31 | + expect(instance.instanceName).toEqual(instanceYaml.name) |
| 32 | + // get src from template by default |
| 33 | + expect(instance.outputs.templateUrl).toBeDefined() |
| 34 | + expect(instance.outputs).toBeDefined() |
| 35 | + expect(instance.outputs.region).toEqual(instanceYaml.inputs.region) |
| 36 | + expect(instance.outputs.scf).toBeDefined() |
| 37 | + expect(instance.outputs.scf.runtime).toEqual(instanceYaml.inputs.runtime) |
| 38 | + expect(instance.outputs.apigw).toBeDefined() |
| 39 | + expect(instance.outputs.apigw.environment).toEqual(instanceYaml.inputs.apigatewayConf.environment) |
| 40 | +}) |
| 41 | + |
| 42 | +it('should successfully remove flask app', async () => { |
| 43 | + await sdk.remove(instanceYaml, credentials) |
| 44 | + result = await sdk.getInstance( |
| 45 | + instanceYaml.org, |
| 46 | + instanceYaml.stage, |
| 47 | + instanceYaml.app, |
| 48 | + instanceYaml.name |
| 49 | + ) |
| 50 | + |
| 51 | + // remove action won't delete the service cause the apigw have the api binded |
| 52 | + expect(result.instance.instanceStatus).toEqual('inactive') |
| 53 | +}) |
0 commit comments