/
manifest.spec.ts
67 lines (64 loc) · 1.82 KB
/
manifest.spec.ts
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
import { expect } from 'chai';
import { ManifestStack, stackToWire } from '../../src/runtime/manifest';
import * as params from '../../src/v2/params';
describe('stackToWire', () => {
afterEach(() => {
params.clearParams();
});
it('converts Expression types in endpoint options to CEL', () => {
const intParam = params.defineInt('foo', { default: 11 });
const stringParam = params.defineString('bar', {
default: 'America/Los_Angeles',
});
const stack: ManifestStack = {
endpoints: {
v2http: {
platform: 'gcfv2',
entryPoint: 'v2http',
labels: {},
httpsTrigger: {},
concurrency: intParam,
maxInstances: intParam.equals(24).then(-1, 1),
},
v2schedule: {
platform: 'gcfv2',
entryPoint: 'v2callable',
labels: {},
scheduleTrigger: {
schedule: stringParam
.equals('America/Mexico_City')
.then('mexico', 'usa'),
timeZone: stringParam,
},
},
},
requiredAPIs: [],
specVersion: 'v1alpha1',
};
const expected = {
endpoints: {
v2http: {
platform: 'gcfv2',
entryPoint: 'v2http',
labels: {},
httpsTrigger: {},
concurrency: '{{ params.foo }}',
maxInstances: '{{ params.foo == 24 ? -1 : 1 }}',
},
v2schedule: {
platform: 'gcfv2',
entryPoint: 'v2callable',
labels: {},
scheduleTrigger: {
schedule:
'{{ params.bar == "America/Mexico_City" ? "mexico" : "usa" }}',
timeZone: '{{ params.bar }}',
},
},
},
requiredAPIs: [],
specVersion: 'v1alpha1',
};
expect(stackToWire(stack)).to.deep.equal(expected);
});
});