From c7ad7b432dfb7b6ae0d8cbd1d8e7210f98f5b4bb Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Thu, 27 Jun 2019 11:40:43 -0400 Subject: [PATCH] Add tests --- __tests__/finder.test.ts | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/__tests__/finder.test.ts b/__tests__/finder.test.ts index 6ad7638..44f10bd 100644 --- a/__tests__/finder.test.ts +++ b/__tests__/finder.test.ts @@ -30,11 +30,41 @@ process.env['RUNNER_TEMPDIRECTORY'] = tempDir; import * as finder from '../src/find-python'; describe('Finder tests', () => { - it('Finds Python if it is installed', async () => {}); + it('Finds Python if it is installed', async () => { + const pythonDir: string = path.join(toolDir, 'python', '2.0.0', 'x64'); + await io.mkdirP(pythonDir); + fs.writeFileSync(`${pythonDir}.complete`, 'hello'); + // This will throw if it doesn't find it in the cache (because no such version exists) + await finder.findPythonVersion('2.x', 'x64'); + }); - it('Errors if Python is not installed', async () => {}); + it('Errors if Python is not installed', async () => { + // This will throw if it doesn't find it in the cache (because no such version exists) + let thrown = false; + try { + await finder.findPythonVersion('3.x', 'x64'); + } catch { + thrown = true; + } + expect(thrown).toBeTruthy(); + }); - it('Finds PyPy if it is installed', async () => {}); + it('Finds PyPy if it is installed', async () => { + const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64'); + await io.mkdirP(pythonDir); + fs.writeFileSync(`${pythonDir}.complete`, 'hello'); + // This will throw if it doesn't find it in the cache (because no such version exists) + await finder.findPythonVersion('pypy2', 'x64'); + }); - it('Errors if PyPy is not installed', async () => {}); + it('Errors if PyPy is not installed', async () => { + // This will throw if it doesn't find it in the cache (because no such version exists) + let thrown = false; + try { + await finder.findPythonVersion('pypy3', 'x64'); + } catch { + thrown = true; + } + expect(thrown).toBeTruthy(); + }); });