-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpip.test.ts
More file actions
95 lines (90 loc) · 2.85 KB
/
Copy pathpip.test.ts
File metadata and controls
95 lines (90 loc) · 2.85 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
import { describe, expect, it } from 'vitest'
import { PluginTester, testSpawn } from '@codifycli/plugin-test';
import * as path from 'node:path';
import fs from 'node:fs';
import os from 'node:os';
describe('Pip resource integration tests', () => {
const pluginPath = path.resolve('./src/index.ts');
it('Installs python', { timeout: 500000 }, async () => {
await PluginTester.fullTest(pluginPath, [
{
type: 'uv',
pythonVersions: ['3.11'],
global: '3.11',
tools: ['pip'],
},
], {
skipUninstall: true,
validateApply: async () => {
expect((await testSpawn('python --version')).data).to.include('3.11');
}
})
})
it('Installs python and installs a package using pip', { timeout: 300000 }, async () => {
const requirementsPath = path.join(os.homedir(), 'requirements.txt')
fs.writeFileSync(requirementsPath, 'aayush-color')
await PluginTester.fullTest(pluginPath, [
{
type: 'pip',
install: [
'ffmpeg',
{ name: 'qoverage', version: "0.1.12"},
],
installFiles: [requirementsPath]
}
], {
skipUninstall: true,
validatePlan: (plans) => {
console.log(JSON.stringify(plans, null, 2))
},
validateApply: async () => {
const installedDependencies = await testSpawn('pip list --format=json --disable-pip-version-check');
const parsed = JSON.parse(installedDependencies.data) as Array<{ name: string; version: string; }>;
expect(parsed.some((p) => p.name === 'ffmpeg')).to.be.true;
expect(parsed.some((p) => p.name === 'qoverage' && p.version === '0.1.12')).to.be.true;
},
testModify: {
modifiedConfigs: [
{
type: 'pip',
install: [
'ffmpeg',
'ansible-roster',
{ name: 'qoverage', version: "0.1.13"},
]
}
],
validateModify: (plans) => {
expect(plans.length).to.eq(1);
const plan = plans[0];
expect(plan).toMatchObject( {
"operation": "modify",
"resourceType": "pip",
"parameters": expect.arrayContaining([
expect.objectContaining({
"name": "install",
"previousValue": [
"ffmpeg",
{
"name": "qoverage",
"version": "0.1.12"
}
],
"newValue": [
"ffmpeg",
"ansible-roster",
{
"name": "qoverage",
"version": "0.1.13"
}
],
"operation": "modify"
})
])
}
)
}
}
});
});
})