-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathandroid-cli.test.ts
More file actions
102 lines (92 loc) · 3.18 KB
/
Copy pathandroid-cli.test.ts
File metadata and controls
102 lines (92 loc) · 3.18 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
92
93
94
95
96
97
98
99
100
101
102
import { PluginTester, testSpawn } from '@codifycli/plugin-test';
import { SpawnStatus } from '@codifycli/schemas';
import * as path from 'node:path';
import * as os from 'node:os';
import { beforeAll, describe, expect, it } from 'vitest';
const isLinuxArm = os.platform() === 'linux' && os.arch() === 'arm64';
describe.skipIf(isLinuxArm)('Android CLI integration tests', async () => {
const pluginPath = path.resolve('./src/index.ts');
beforeAll(async () => {
const result = await testSpawn('which android');
if (result.status === SpawnStatus.SUCCESS) {
await PluginTester.uninstall(pluginPath, [{ type: 'android-cli' }]);
}
}, 120_000);
it('Can install and uninstall Android CLI', { timeout: 300_000 }, async () => {
await PluginTester.fullTest(
pluginPath,
[{ type: 'android-cli' }],
{
validateApply: async () => {
const result = await testSpawn('which android');
expect(result.status).toBe(SpawnStatus.SUCCESS);
},
validateDestroy: async () => {
const result = await testSpawn('which android');
expect(result.status).toBe(SpawnStatus.ERROR);
},
}
);
});
it('Can install Android CLI with SDK packages', { timeout: 600_000 }, async () => {
await PluginTester.fullTest(
pluginPath,
[
{
type: 'android-cli',
sdkPackages:['cmdline-tools/latest', 'platform-tools'],
},
],
{
validateApply: async () => {
const which = await testSpawn('which android');
expect(which.status).toBe(SpawnStatus.SUCCESS);
const list = await testSpawn('android sdk list');
expect(list.status).toBe(SpawnStatus.SUCCESS);
expect(list.data).toContain('platform-tools');
},
validateDestroy: async () => {
const result = await testSpawn('which android');
expect(result.status).toBe(SpawnStatus.ERROR);
},
}
);
});
});
describe.skipIf(isLinuxArm)('Android Emulator integration tests', async () => {
const pluginPath = path.resolve('./src/index.ts');
beforeAll(async () => {
const result = await testSpawn('which android');
if (result.status === SpawnStatus.SUCCESS) {
await PluginTester.uninstall(pluginPath, [{ type: 'android-cli' }]);
}
}, 120_000);
it('Can create and destroy an Android emulator', { timeout: 900_000 }, async () => {
await PluginTester.fullTest(
pluginPath,
[
{
type: 'android-cli',
sdkPackages: [
'cmdline-tools/latest',
'platform-tools',
'platforms/android-35',
'system-images/android-35/google_apis_playstore/x86_64',
],
emulators: ['medium_phone'],
},
],
{
validateApply: async () => {
const list = await testSpawn('android emulator list');
expect(list.status).toBe(SpawnStatus.SUCCESS);
expect(list.data).toContain('medium_phone');
},
validateDestroy: async () => {
const list = await testSpawn('android emulator list');
expect(list.data).not.toContain('medium_phone');
},
}
);
});
});