-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathdocker.test.ts
81 lines (74 loc) · 1.96 KB
/
docker.test.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { spawnSync } from 'child_process';
import * as path from 'path';
const docker = process.env.CDK_DOCKER ?? 'docker';
beforeAll(() => {
const process = spawnSync(docker, ['build', '-t', 'esbuild', path.join(__dirname, '..', 'lib')], { stdio: 'inherit' });
expect(process.error).toBeUndefined();
expect(process.status).toBe(0);
});
test('esbuild is available', () => {
const proc = spawnSync(docker, [
'run', 'esbuild',
'esbuild', '--version',
]);
expect(proc.status).toEqual(0);
});
test('can npm install with non root user', () => {
const proc = spawnSync(docker, [
'run', '-u', '1000:1000',
'esbuild',
'bash', '-c', [
'mkdir /tmp/test',
'cd /tmp/test',
'npm i constructs',
].join(' && '),
]);
expect(proc.status).toEqual(0);
});
test('can yarn install with non root user', () => {
const proc = spawnSync(docker, [
'run', '-u', '500:500',
'esbuild',
'bash', '-c', [
'mkdir /tmp/test',
'cd /tmp/test',
'yarn add constructs',
].join(' && '),
]);
expect(proc.status).toEqual(0);
});
test('can pnpm install with non root user', () => {
const proc = spawnSync(docker, [
'run', '-u', '500:500',
'esbuild',
'bash', '-c', [
'mkdir /tmp/test',
'cd /tmp/test',
'pnpm add constructs',
].join(' && '),
]);
expect(proc.status).toEqual(0);
});
test('can bun install with non root user', () => {
const proc = spawnSync(docker, [
'run', '-u', '500:500',
'esbuild',
'bash', '-c', [
'mkdir /tmp/test',
'cd /tmp/test',
'bun add constructs',
].join(' && '),
]);
expect(proc.status).toEqual(0);
});
test('cache folders have the right permissions', () => {
const proc = spawnSync(docker, [
'run', 'esbuild',
'bash', '-c', [
'stat -c \'%a\' /tmp/npm-cache',
'stat -c \'%a\' /tmp/yarn-cache',
'stat -c \'%a\' /tmp/pnpm-cache',
].join(' && '),
]);
expect(proc.stdout.toString()).toMatch('777\n777');
});