Skip to content

Commit c7ad7b4

Browse files
author
Danny McCormick
committed
Add tests
1 parent 39c08a0 commit c7ad7b4

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

__tests__/finder.test.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,41 @@ process.env['RUNNER_TEMPDIRECTORY'] = tempDir;
3030
import * as finder from '../src/find-python';
3131

3232
describe('Finder tests', () => {
33-
it('Finds Python if it is installed', async () => {});
33+
it('Finds Python if it is installed', async () => {
34+
const pythonDir: string = path.join(toolDir, 'python', '2.0.0', 'x64');
35+
await io.mkdirP(pythonDir);
36+
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
37+
// This will throw if it doesn't find it in the cache (because no such version exists)
38+
await finder.findPythonVersion('2.x', 'x64');
39+
});
3440

35-
it('Errors if Python is not installed', async () => {});
41+
it('Errors if Python is not installed', async () => {
42+
// This will throw if it doesn't find it in the cache (because no such version exists)
43+
let thrown = false;
44+
try {
45+
await finder.findPythonVersion('3.x', 'x64');
46+
} catch {
47+
thrown = true;
48+
}
49+
expect(thrown).toBeTruthy();
50+
});
3651

37-
it('Finds PyPy if it is installed', async () => {});
52+
it('Finds PyPy if it is installed', async () => {
53+
const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64');
54+
await io.mkdirP(pythonDir);
55+
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
56+
// This will throw if it doesn't find it in the cache (because no such version exists)
57+
await finder.findPythonVersion('pypy2', 'x64');
58+
});
3859

39-
it('Errors if PyPy is not installed', async () => {});
60+
it('Errors if PyPy is not installed', async () => {
61+
// This will throw if it doesn't find it in the cache (because no such version exists)
62+
let thrown = false;
63+
try {
64+
await finder.findPythonVersion('pypy3', 'x64');
65+
} catch {
66+
thrown = true;
67+
}
68+
expect(thrown).toBeTruthy();
69+
});
4070
});

0 commit comments

Comments
 (0)