-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuv.test.ts
More file actions
72 lines (66 loc) · 2.32 KB
/
Copy pathuv.test.ts
File metadata and controls
72 lines (66 loc) · 2.32 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
import { SpawnStatus } from '@codifycli/plugin-core';
import { PluginTester, testSpawn } from '@codifycli/plugin-test';
import { afterAll, describe, expect, it } from 'vitest';
import * as path from 'node:path';
describe('uv resource integration tests', () => {
const pluginPath = path.resolve('./src/index.ts');
it('Installs uv and manages Python versions', { timeout: 300_000 }, async () => {
await PluginTester.fullTest(pluginPath, [
{
type: 'uv',
pythonVersions: ['3.12'],
},
], {
validateApply: async () => {
expect(await testSpawn('uv --version')).toMatchObject({ status: SpawnStatus.SUCCESS });
const { data: pythonList } = await testSpawn('uv python list --only-installed');
expect(pythonList).toContain('3.12');
},
validateDestroy: async () => {
expect(await testSpawn('uv --version')).toMatchObject({ status: SpawnStatus.ERROR });
},
});
});
it('Installs uv and sets a global default Python', { timeout: 300_000 }, async () => {
await PluginTester.fullTest(pluginPath, [
{
type: 'uv',
pythonVersions: ['3.12'],
global: '3.12',
},
], {
validateApply: async () => {
const { data: version } = await testSpawn('python --version');
expect(version).toContain('3.12');
},
validateDestroy: async () => {
expect(await testSpawn('uv --version')).toMatchObject({ status: SpawnStatus.ERROR });
},
});
});
it('Installs uv and manages global tools', { timeout: 300_000 }, async () => {
await PluginTester.fullTest(pluginPath, [
{
type: 'uv',
tools: ['ruff'],
},
], {
validateApply: async () => {
expect(await testSpawn('uv --version')).toMatchObject({ status: SpawnStatus.SUCCESS });
expect(await testSpawn('uv tool list')).toMatchObject({
status: SpawnStatus.SUCCESS,
data: expect.stringContaining('ruff'),
});
},
validateDestroy: async () => {
expect(await testSpawn('uv --version')).toMatchObject({ status: SpawnStatus.ERROR });
},
});
});
afterAll(async () => {
const { status } = await testSpawn('uv --version');
if (status === SpawnStatus.SUCCESS) {
await PluginTester.uninstall(pluginPath, [{ type: 'uv' }]);
}
}, 60_000);
});