-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4db2a8a
commit 51fca42
Showing
3 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ns/positron-python/src/test/pythonEnvironments/creation/provider/commonUtils.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { expect } from 'chai'; | ||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
import * as sinon from 'sinon'; | ||
import { Uri } from 'vscode'; | ||
import { hasVenv } from '../../../../client/pythonEnvironments/creation/common/commonUtils'; | ||
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants'; | ||
|
||
suite('CommonUtils', () => { | ||
let fileExistsStub: sinon.SinonStub; | ||
const workspace1 = { | ||
uri: Uri.file(path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'testMultiRootWkspc', 'workspace1')), | ||
name: 'workspace1', | ||
index: 0, | ||
}; | ||
|
||
setup(() => { | ||
fileExistsStub = sinon.stub(fs, 'pathExists'); | ||
}); | ||
|
||
teardown(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
test('Venv exists test', async () => { | ||
fileExistsStub.resolves(true); | ||
const result = await hasVenv(workspace1); | ||
expect(result).to.be.equal(true, 'Incorrect result'); | ||
|
||
fileExistsStub.calledOnceWith(path.join(workspace1.uri.fsPath, '.venv', 'pyvenv.cfg')); | ||
}); | ||
|
||
test('Venv does not exist test', async () => { | ||
fileExistsStub.resolves(false); | ||
const result = await hasVenv(workspace1); | ||
expect(result).to.be.equal(false, 'Incorrect result'); | ||
|
||
fileExistsStub.calledOnceWith(path.join(workspace1.uri.fsPath, '.venv', 'pyvenv.cfg')); | ||
}); | ||
}); |