Skip to content

Commit becb461

Browse files
committed
chore: add tests for pip-sync
1 parent 5fa5c87 commit becb461

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

test/python/pip-sync.test.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { PluginTester } from 'codify-plugin-test';
2+
import { ResourceOperation } from 'codify-schemas';
3+
import { execSync } from 'node:child_process';
4+
import fs from 'node:fs';
5+
import os from 'node:os';
6+
import * as path from 'node:path';
7+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
8+
9+
describe('Pip-sync resource integration tests', () => {
10+
const pluginPath = path.resolve('./src/index.ts');
11+
12+
it('Installs python', { timeout: 500_000 }, async () => {
13+
await PluginTester.fullTest(pluginPath, [
14+
{
15+
type: 'pyenv',
16+
pythonVersions: ['3.11'],
17+
global: '3.11'
18+
},
19+
], {
20+
skipUninstall: true,
21+
validateApply() {
22+
expect(execSync('source ~/.zshrc; python --version', { shell: 'zsh' }).toString()).to.include('3.11');
23+
}
24+
})
25+
})
26+
27+
it('Installs python and installs packages via pip-sync (in venv)', { timeout: 300_000 }, async () => {
28+
await PluginTester.fullTest(pluginPath, [
29+
{
30+
'type': 'git-repository',
31+
'directory': '~/Projects/example-project2',
32+
'repository': 'https://github.com/daniel-dqsdatalabs/python-template.git'
33+
},
34+
{
35+
'type': 'venv-project',
36+
'envDir': '.venv',
37+
'cwd': '~/Projects/example-project2',
38+
'dependsOn': ['git-repository']
39+
},
40+
{
41+
'type': 'pip-sync',
42+
'cwd': '~/Projects/example-project2',
43+
'requirementFiles': ['requirements.txt', 'dev-requirements.txt'],
44+
'virtualEnv': '.venv',
45+
'dependsOn': ['venv-project']
46+
},
47+
], {
48+
skipUninstall: true,
49+
validatePlan(plans) {
50+
console.log(JSON.stringify(plans, null, 2))
51+
},
52+
validateApply() {},
53+
});
54+
});
55+
})

0 commit comments

Comments
 (0)