mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
findAzdata test fix (#11724)
* findAzdata test fix * cleanup * pr feedback
This commit is contained in:
@@ -26,14 +26,23 @@ describe('azdata', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('findAzdata', function () {
|
describe('findAzdata', function () {
|
||||||
// Mock call to --version to simulate azdata being installed
|
|
||||||
sinon.stub(childProcess, 'executeCommand').returns(Promise.resolve({ stdout: 'v1.0.0', stderr: '' }));
|
|
||||||
it('successful', async function (): Promise<void> {
|
it('successful', async function (): Promise<void> {
|
||||||
sinon.stub(utils, 'searchForCmd').returns(Promise.resolve('C:\\path\\to\\azdata.cmd'));
|
if (process.platform === 'win32') {
|
||||||
|
// Mock searchForCmd to return a path to azdata.cmd
|
||||||
|
sinon.stub(utils, 'searchForCmd').returns(Promise.resolve('C:\\path\\to\\azdata.cmd'));
|
||||||
|
}
|
||||||
|
// Mock call to --version to simulate azdata being installed
|
||||||
|
sinon.stub(childProcess, 'executeCommand').returns(Promise.resolve({ stdout: 'v1.0.0', stderr: '' }));
|
||||||
await should(azdata.findAzdata(outputChannelMock.object)).not.be.rejected();
|
await should(azdata.findAzdata(outputChannelMock.object)).not.be.rejected();
|
||||||
});
|
});
|
||||||
it('unsuccessful', async function (): Promise<void> {
|
it('unsuccessful', async function (): Promise<void> {
|
||||||
sinon.stub(utils, 'searchForCmd').returns(Promise.reject(new Error('Could not find azdata')));
|
if (process.platform === 'win32') {
|
||||||
|
// Mock searchForCmd to return a failure to find azdata.cmd
|
||||||
|
sinon.stub(utils, 'searchForCmd').returns(Promise.reject(new Error('Could not find azdata')));
|
||||||
|
} else {
|
||||||
|
// Mock call to executeCommand to simulate azdata --version returning error
|
||||||
|
sinon.stub(childProcess, 'executeCommand').returns(Promise.reject({ stdout: '', stderr: 'command not found: azdata' }));
|
||||||
|
}
|
||||||
await should(azdata.findAzdata(outputChannelMock.object)).be.rejected();
|
await should(azdata.findAzdata(outputChannelMock.object)).be.rejected();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user