-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.test.js
89 lines (82 loc) · 2.86 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const { generateId, getServerlessSdk } = require('./lib/utils')
const instanceYaml = {
org: 'orgDemo',
app: 'appDemo',
component: 'postgresql@dev',
name: `postgresql-integration-tests-${generateId()}`,
stage: 'dev',
inputs: {
region: 'ap-guangzhou',
zone: 'ap-guangzhou-2',
dBInstanceName: "serverless-test",
vpcConfig: {
vpcId: 'vpc-b6531flb',
subnetId: 'subnet-eexos4wi',
},
}
}
const credentials = {
tencent: {
SecretId: process.env.TENCENT_SECRET_ID,
SecretKey: process.env.TENCENT_SECRET_KEY,
}
}
const sdk = getServerlessSdk(instanceYaml.org)
describe('Postgresql', () => {
it('deploy postgresql success', async () => {
const instance = await sdk.deploy(instanceYaml, credentials)
expect(instance).toBeDefined()
expect(instance.instanceName).toEqual(instanceYaml.name)
expect(instance.outputs).toEqual({
region: instanceYaml.inputs.region,
zone: instanceYaml.inputs.zone,
vpcConfig: instanceYaml.inputs.vpcConfig,
dBInstanceName: instanceYaml.inputs.dBInstanceName,
dBInstanceId: expect.stringContaining('postgres-'),
private: {
connectionString: expect.stringContaining('postgresql://'),
host: expect.any(String),
port: 5432,
user: expect.stringContaining('tencentdb_'),
password: expect.any(String),
dbname: expect.stringContaining('tencentdb_'),
},
vendorMessage: null,
});
})
it('update postgresql success', async () => {
instanceYaml.inputs.extranetAccess = true
const instance = await sdk.deploy(instanceYaml, credentials)
expect(instance).toBeDefined()
expect(instance.instanceName).toEqual(instanceYaml.name)
expect(instance.outputs).toEqual({
region: instanceYaml.inputs.region,
zone: instanceYaml.inputs.zone,
vpcConfig: instanceYaml.inputs.vpcConfig,
dBInstanceName: instanceYaml.inputs.dBInstanceName,
dBInstanceId: expect.stringContaining('postgres-'),
private: {
connectionString: expect.stringContaining('postgresql://'),
host: expect.any(String),
port: 5432,
user: expect.stringContaining('tencentdb_'),
password: expect.any(String),
dbname: expect.stringContaining('tencentdb_'),
},
public: {
connectionString: expect.stringContaining('postgresql://'),
host: expect.any(String),
port: expect.any(Number),
user: expect.stringContaining('tencentdb_'),
password: expect.any(String),
dbname: expect.stringContaining('tencentdb_'),
},
vendorMessage: null,
});
})
it('remove postgresql success', async () => {
await sdk.remove(instanceYaml, credentials)
result = await sdk.getInstance(instanceYaml.org, instanceYaml.stage, instanceYaml.app, instanceYaml.name)
expect(result.instance.instanceStatus).toEqual('inactive')
})
})