forked from cargo-lambda/cargo-lambda-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.test.ts
More file actions
91 lines (75 loc) · 2.29 KB
/
function.test.ts
File metadata and controls
91 lines (75 loc) · 2.29 KB
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
90
91
import { join } from 'path';
import { env } from 'process';
import { App, Stack } from 'aws-cdk-lib';
import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
import { RustFunction, cargoLambdaVersion } from '../src/index';
const forcedDockerBundling = !!env.FORCE_DOCKER_RUN || !cargoLambdaVersion();
describe('CargoLambda.RustFunction', () => {
describe('With single package Cargo project', () => {
const app = new App();
const stack = new Stack(app);
const testSource = join(__dirname, 'fixtures/single-package');
new RustFunction(stack, 'rust function', {
manifestPath: testSource,
bundling: {
forcedDockerBundling,
},
});
test('bundle function', () => {
app.synth();
});
});
describe('With a Cargo workspace', () => {
const app = new App();
const stack = new Stack(app);
const testSource = join(__dirname, 'fixtures/cargo-workspace');
new RustFunction(stack, 'rust function 1', {
manifestPath: join(testSource, 'binary1'),
binaryName: 'binary1',
bundling: {
forcedDockerBundling,
},
});
new RustFunction(stack, 'rust function 2', {
manifestPath: join(testSource, 'binary2'),
binaryName: 'binary2',
bundling: {
forcedDockerBundling,
},
});
test('bundle function', () => {
app.synth();
});
});
describe('With the legacy provided.al2 runtime', () => {
const app = new App();
const stack = new Stack(app);
const testSource = join(__dirname, 'fixtures/single-package');
new RustFunction(stack, 'rust function', {
manifestPath: testSource,
runtime: 'provided.al2',
bundling: {
forcedDockerBundling,
},
});
test('bundle function', () => {
app.synth();
});
});
describe('With log group specified', () => {
const app = new App();
const stack = new Stack(app);
const testSource = join(__dirname, 'fixtures/single-package');
const logGroup = new LogGroup(stack, 'LogGroup', {
retention: RetentionDays.ONE_WEEK,
});
const rustFunction = new RustFunction(stack, 'rust function', {
manifestPath: testSource,
logGroup: logGroup,
});
logGroup.grantWrite(rustFunction);
test('bundle function', () => {
app.synth();
});
});
});