cleanup tests (#19732)

This commit is contained in:
Vasu Bhog
2022-06-15 11:08:49 -07:00
committed by GitHub
parent 909c56ffe3
commit 4d320c56f0
4 changed files with 49 additions and 49 deletions

View File

@@ -39,7 +39,7 @@ describe('Add Connection String Execute Step', () => {
// getConnectionString should return a connection string with the password
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve(testConnectionString));
// Include Password Prompt - Yes to include password
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').onFirstCall().returns(Promise.resolve(constants.yesString) as any);
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').onFirstCall().resolves((constants.yesString) as any);
// setup stub for setting local app setting with connection string
sinon.stub(fs.promises, 'writeFile');
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, sinon.match.any, sinon.match.any).resolves(true);
@@ -50,12 +50,12 @@ describe('Add Connection String Execute Step', () => {
should(quickPickStub.calledOnce).be.true('showQuickPick should have been called');
should(getSettingsFileSpy.calledOnce).be.true('GetSettingsFile method should be called once');
should(addConnectionStringSpy.calledOnce).be.true('addConnectionStringSpy method should be called once');
testExecuteStep.shouldExecute(TypeMoq.It.isAny()).should.be.true();
testExecuteStep.shouldExecute(TypeMoq.It.isAny()).should.be.true('Should execute should be true');
});
it('Should return if no settings file found when creating a new Azure Functions project', async () => {
// stubs and spies for methods in the execute step
let getSettingsFileSpy = sinon.stub(azureFunctionUtils, 'getSettingsFile').withArgs(rootFolderPath).returns(Promise.resolve(undefined));
let getSettingsFileSpy = sinon.stub(azureFunctionUtils, 'getSettingsFile').withArgs(rootFolderPath).resolves((undefined));
let connectionInfo: IConnectionInfo = createTestCredentials();// Mocks promptForConnection
let quickPickStub = sinon.spy(vscode.window, 'showQuickPick');
let addConnectionStringToConfigStub = sinon.spy(azureFunctionUtils, 'addConnectionStringToConfig');
@@ -73,7 +73,7 @@ describe('Add Connection String Execute Step', () => {
// stubs and spies for methods in the execute step
let getSettingsFileSpy = sinon.spy(azureFunctionUtils, 'getSettingsFile').withArgs(rootFolderPath);
let connectionInfo: IConnectionInfo = createTestCredentials();// Mocks promptForConnection
sinon.stub(azureFunctionUtils, 'promptConnectionStringPasswordAndUpdateConnectionString').withArgs(connectionInfo, localSettingsPath).returns(Promise.resolve(undefined));
sinon.stub(azureFunctionUtils, 'promptConnectionStringPasswordAndUpdateConnectionString').withArgs(connectionInfo, localSettingsPath).resolves((undefined));
let addConnectionStringToConfigStub = sinon.spy(azureFunctionUtils, 'addConnectionStringToConfig');
// call execute step on the AzureWizardExecuteStep

View File

@@ -46,7 +46,7 @@ describe('AzureFunctionUtils', function (): void {
let writeFileStub = sinon.stub(fs.promises, 'writeFile');
await azureFunctionsUtils.setLocalAppSetting(path.dirname(localSettingsPath), 'test4', 'test4');
should(writeFileStub.calledWithExactly(localSettingsPath, `{\n "IsEncrypted": false,\n "Values": {\n "test1": "test1",\n "test2": "test2",\n "test3": "test3",\n "test4": "test4"\n }\n}`)).equals(true);
should(writeFileStub.calledWithExactly(localSettingsPath, `{\n "IsEncrypted": false,\n "Values": {\n "test1": "test1",\n "test2": "test2",\n "test3": "test3",\n "test4": "test4"\n }\n}`)).equals(true, 'writeFile should be called with the correct arguments');
});
it('Should not overwrite setting if value already exists in local.settings.json', async () => {
@@ -57,11 +57,11 @@ describe('AzureFunctionUtils', function (): void {
);
let warningMsg = constants.settingAlreadyExists('test1');
const spy = sinon.stub(vscode.window, 'showWarningMessage').resolves({ title: constants.settingAlreadyExists('test1') });
const showErrorMessageSpy = sinon.stub(vscode.window, 'showWarningMessage').resolves({ title: constants.settingAlreadyExists('test1') });
await azureFunctionsUtils.setLocalAppSetting(path.dirname(localSettingsPath), 'test1', 'newValue');
should(spy.calledOnce).be.true('showWarningMessage should have been called exactly once');
should(spy.calledWith(warningMsg)).be.true(`showWarningMessage not called with expected message '${warningMsg}' Actual '${spy.getCall(0).args[0]}'`);
should(showErrorMessageSpy.calledOnce).be.true('showWarningMessage should have been called exactly once');
should(showErrorMessageSpy.calledWith(warningMsg)).be.true(`showWarningMessage not called with expected message '${warningMsg}' Actual '${showErrorMessageSpy.getCall(0).args[0]}'`);
});
it('Should get settings file given project file', async () => {
@@ -79,7 +79,7 @@ describe('AzureFunctionUtils', function (): void {
let writeFileStub = sinon.stub(fs.promises, 'writeFile');
await azureFunctionsUtils.addConnectionStringToConfig(connectionString, rootFolderPath);
should(writeFileStub.calledWithExactly(localSettingsPath, `{\n "IsEncrypted": false,\n "Values": {\n "test1": "test1",\n "test2": "test2",\n "test3": "test3",\n "SqlConnectionString": "testConnectionString"\n }\n}`)).equals(true);
should(writeFileStub.calledWithExactly(localSettingsPath, `{\n "IsEncrypted": false,\n "Values": {\n "test1": "test1",\n "test2": "test2",\n "test3": "test3",\n "SqlConnectionString": "testConnectionString"\n }\n}`)).equals(true, 'writeFile should be called with the correct arguments');
});
});
@@ -93,7 +93,7 @@ describe('AzureFunctionUtils', function (): void {
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve(`Server=${connectionInfo.server};Initial Catalog=${connectionInfo.database};User ID=${connectionInfo.user};Password=${connectionInfo.password};`));
// Include Password Prompt - Yes to include password
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').onFirstCall().returns(Promise.resolve(constants.yesString) as any);
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').onFirstCall().resolves((constants.yesString) as any);
// Manually enter password
let quickInputSpy = sinon.spy(vscode.window, 'showInputBox');
// show warning window
@@ -106,7 +106,7 @@ describe('AzureFunctionUtils', function (): void {
should(quickInputSpy.notCalled).be.true('showInputBox should not have been called');
should(warningSpy.notCalled).be.true('showWarningMessage should not have been called');
// get connection string result
should(getConnectionString).equals(`Server=${connectionInfo.server};Initial Catalog=${connectionInfo.database};User ID=${connectionInfo.user};Password=${connectionInfo.password};`);
should(getConnectionString).equals(`Server=${connectionInfo.server};Initial Catalog=${connectionInfo.database};User ID=${connectionInfo.user};Password=${connectionInfo.password};`,'Should return a connection string with the password');
});
it('Should not include password and show warning if user does not want to include password prompt and connection info contains the password and auth type is SQL', async () => {
@@ -118,7 +118,7 @@ describe('AzureFunctionUtils', function (): void {
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, false, false)).returns(() => Promise.resolve(`Server=${connectionInfo.server};Initial Catalog=${connectionInfo.database};User ID=${connectionInfo.user};Password=${constants.passwordPlaceholder};`));
// Include Password Prompt - NO to include password
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').onFirstCall().returns(Promise.resolve(constants.noString) as any);
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').onFirstCall().resolves((constants.noString) as any);
// Manually enter password
let quickInputSpy = sinon.spy(vscode.window, 'showInputBox');
// show warning window
@@ -131,7 +131,7 @@ describe('AzureFunctionUtils', function (): void {
should(quickInputSpy.notCalled).be.true('showInputBox should not have been called');
should(warningSpy.calledOnce).be.true('showWarningMessage should have been called');
// returned connection string should NOT include password
should(getConnectionString).equals(`Server=${connectionInfo.server};Initial Catalog=${connectionInfo.database};User ID=${connectionInfo.user};Password=${constants.passwordPlaceholder};`);
should(getConnectionString).equals(`Server=${connectionInfo.server};Initial Catalog=${connectionInfo.database};User ID=${connectionInfo.user};Password=${constants.passwordPlaceholder};`,'Should return a connection string without the password');
});
it('Should not include password and show warning if user cancels include password prompt and connection info contains the password and auth type is SQL', async () => {
@@ -268,7 +268,7 @@ describe('AzureFunctionUtils', function (): void {
// only one azure function project found - hostFiles and csproj files stubs
let findFilesStub = sinon.stub(vscode.workspace, 'findFiles');
findFilesStub.onFirstCall().resolves([vscode.Uri.file('/temp/host.json')]);
findFilesStub.onSecondCall().returns(Promise.resolve([vscode.Uri.file('/temp/test.csproj')]) as any);
findFilesStub.onSecondCall().resolves(([vscode.Uri.file('/temp/test.csproj')]) as any);
let result = await azureFunctionsUtils.getAzureFunctionProject();
should(result).be.equal('/temp/test.csproj', 'Should return test.csproj since only one Azure function project is found');
@@ -285,13 +285,13 @@ describe('AzureFunctionUtils', function (): void {
});
// multiple azure function projects found in workspace - hostFiles and project find files stubs
let findFilesStub = sinon.stub(vscode.workspace, 'findFiles');
findFilesStub.onFirstCall().returns(Promise.resolve([vscode.Uri.file('/temp/host.json'), vscode.Uri.file('/temp2/host.json')]) as any);
findFilesStub.onFirstCall().resolves(([vscode.Uri.file('/temp/host.json'), vscode.Uri.file('/temp2/host.json')]) as any);
// we loop through the hostFiles to find the csproj in same directory
// first loop we use host of /temp/host.json
findFilesStub.onSecondCall().returns(Promise.resolve([vscode.Uri.file('/temp/test.csproj')]) as any);
findFilesStub.onSecondCall().resolves(([vscode.Uri.file('/temp/test.csproj')]) as any);
// second loop we use host of /temp2/host.json
findFilesStub.onThirdCall().returns(Promise.resolve([vscode.Uri.file('/temp2/test.csproj')]) as any);
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').returns(Promise.resolve('/temp/test.csproj') as any);
findFilesStub.onThirdCall().resolves(([vscode.Uri.file('/temp2/test.csproj')]) as any);
let quickPickStub = sinon.stub(vscode.window, 'showQuickPick').resolves(('/temp/test.csproj') as any);
let result = await azureFunctionsUtils.getAzureFunctionProject();
should(result).be.equal('/temp/test.csproj', 'Should return test.csproj since user choose Azure function project');
@@ -345,7 +345,7 @@ describe('AzureFunctionUtils', function (): void {
testUtils.vscodeMssqlIExtension.setup(x => x.sendRequest(azureFunctionsContracts.SimpleExecuteRequest.type, params))
.returns(() => Promise.resolve({ rowCount: 1, columnInfo: [], rows: [['[schema].[testTable]']] }));
// select the schema.testTable from list of tables based on connection info and database
quickPickStub.onSecondCall().returns(Promise.resolve('[schema].[testTable]') as any);
quickPickStub.onSecondCall().resolves(('[schema].[testTable]') as any);
let result = await azureFunctionsUtils.promptForObjectName(BindingType.input, connectionInfo);

View File

@@ -60,7 +60,7 @@ describe('Add SQL Binding quick pick', () => {
const showErrorMessageSpy = sinon.spy(vscode.window, 'showErrorMessage');
// select Azure function
let quickpickStub = sinon.stub(vscode.window, 'showQuickPick').returns(Promise.resolve('af1') as any);
let quickpickStub = sinon.stub(vscode.window, 'showQuickPick').resolves(('af1') as any);
// select input or output binding
quickpickStub.onSecondCall().resolves(<any>{ label: constants.input, type: BindingType.input });
sinon.stub(azureFunctionUtils, 'getAFProjectContainingFile').resolves(vscode.Uri.file('testUri'));
@@ -68,14 +68,14 @@ describe('Add SQL Binding quick pick', () => {
quickpickStub.onThirdCall().resolves(<any>{ label: constants.createNewLocalAppSettingWithIcon });
// give connection string setting name
sinon.stub(vscode.window, 'showInputBox').onFirstCall().resolves('sqlConnectionString');
quickpickStub.onCall(3).returns(Promise.resolve(constants.connectionProfile) as any);
quickpickStub.onCall(4).returns(Promise.resolve(constants.yesString) as any);
quickpickStub.onCall(3).resolves((constants.connectionProfile) as any);
quickpickStub.onCall(4).resolves((constants.yesString) as any);
// setLocalAppSetting fails if we dont set writeFile stub
sinon.stub(fs.promises, 'writeFile');
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'sqlConnectionString', 'testConnectionString1').returns(Promise.resolve(true));
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'sqlConnectionString', 'testConnectionString1').resolves((true));
sinon.stub(utils, 'executeCommand').resolves('downloaded nuget package');
quickpickStub.onCall(5).returns(Promise.resolve('testDb') as any);
quickpickStub.onCall(6).returns(Promise.resolve('[schema].[testTable]') as any);
quickpickStub.onCall(5).resolves(('testDb') as any);
quickpickStub.onCall(6).resolves(('[schema].[testTable]') as any);
await launchAddSqlBindingQuickpick(vscode.Uri.file('testUri'));
@@ -113,7 +113,7 @@ describe('Add SQL Binding quick pick', () => {
const showErrorMessageSpy = sinon.spy(vscode.window, 'showErrorMessage');
// select Azure function
let quickpickStub = sinon.stub(vscode.window, 'showQuickPick').returns(Promise.resolve('af1') as any);
let quickpickStub = sinon.stub(vscode.window, 'showQuickPick').resolves(('af1') as any);
// select input or output binding
quickpickStub.onSecondCall().resolves(<any>{ label: constants.input, type: BindingType.input });
sinon.stub(azureFunctionUtils, 'getAFProjectContainingFile').resolves(vscode.Uri.file('testUri'));
@@ -121,14 +121,14 @@ describe('Add SQL Binding quick pick', () => {
quickpickStub.onThirdCall().resolves(<any>{ label: constants.createNewLocalAppSettingWithIcon });
// give connection string setting name
sinon.stub(vscode.window, 'showInputBox').onFirstCall().resolves('sqlConnectionString');
quickpickStub.onCall(3).returns(Promise.resolve(constants.connectionProfile) as any);
quickpickStub.onCall(4).returns(Promise.resolve(constants.yesString) as any);
quickpickStub.onCall(3).resolves((constants.connectionProfile) as any);
quickpickStub.onCall(4).resolves((constants.yesString) as any);
// setLocalAppSetting fails if we dont set writeFile stub
sinon.stub(fs.promises, 'writeFile');
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'sqlConnectionString', 'testConnectionString2').returns(Promise.resolve(true));
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'sqlConnectionString', 'testConnectionString2').resolves((true));
sinon.stub(utils, 'executeCommand').resolves('downloaded nuget package');
quickpickStub.onCall(5).returns(Promise.resolve('testDb') as any);
quickpickStub.onCall(6).returns(Promise.resolve('[schema].[testTable]') as any);
quickpickStub.onCall(5).resolves(('testDb') as any);
quickpickStub.onCall(6).resolves(('[schema].[testTable]') as any);
await launchAddSqlBindingQuickpick(vscode.Uri.file('testUri'));

View File

@@ -52,7 +52,7 @@ describe('AzureFunctionsService', () => {
let connectionDetails = { options: connectionInfo };
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve('testConnectionString'));
const spy = sinon.spy(vscode.window, 'showErrorMessage');
const showErrorMessageSpy = sinon.spy(vscode.window, 'showErrorMessage');
// select input or output binding
let quickpickStub = sinon.stub(vscode.window, 'showQuickPick').resolves(<any>{ label: constants.input, type: BindingType.input });
@@ -62,13 +62,13 @@ describe('AzureFunctionsService', () => {
testUtils.vscodeMssqlIExtension.setup(x => x.connect(connectionInfo)).returns(() => Promise.resolve('testConnectionURI'));
testUtils.vscodeMssqlIExtension.setup(x => x.listDatabases('testConnectionURI')).returns(() => Promise.resolve(['testDb']));
// select the testDB from list of databases based on connection info
quickpickStub.onSecondCall().returns(Promise.resolve('testDb') as any);
quickpickStub.onSecondCall().resolves(('testDb') as any);
// get tables from selected database
const params = { ownerUri: 'testConnectionURI', queryString: azureFunctionUtils.tablesQuery('testDb') };
testUtils.vscodeMssqlIExtension.setup(x => x.sendRequest(azureFunctionsContracts.SimpleExecuteRequest.type, params))
.returns(() => Promise.resolve({ rowCount: 1, columnInfo: [], rows: [['[schema].[testTable]']] }));
// select the schema.testTable from list of tables based on connection info and database
quickpickStub.onThirdCall().returns(Promise.resolve('[schema].[testTable]') as any);
quickpickStub.onThirdCall().resolves(('[schema].[testTable]') as any);
// set azure function name
let inputStub = sinon.stub(vscode.window, 'showInputBox').resolves('testFunctionName');
@@ -77,21 +77,21 @@ describe('AzureFunctionsService', () => {
quickpickStub.onCall(3).resolves(<any>{ label: constants.createNewLocalAppSettingWithIcon });
inputStub.onSecondCall().resolves('SqlConnectionString');
// promptConnectionStringPasswordAndUpdateConnectionString - tested in AzureFunctionUtils.test.ts
quickpickStub.onCall(4).returns(Promise.resolve(constants.yesString) as any);
quickpickStub.onCall(4).resolves((constants.yesString) as any);
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve('testConnectionString'));
// setLocalAppSetting with connection string setting name and connection string
// fails if we dont set writeFile stub
sinon.stub(fs.promises, 'writeFile');
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'SqlConnectionString', 'testConnectionString').returns(Promise.resolve(true));
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'SqlConnectionString', 'testConnectionString').resolves((true));
sinon.stub(utils, 'executeCommand').resolves('downloaded nuget package');
const testWatcher = TypeMoq.Mock.ofType<vscode.FileSystemWatcher>().object;
sinon.stub(azureFunctionUtils, 'waitForNewFunctionFile').withArgs(sinon.match.any).returns({ filePromise: Promise.resolve('TestFileCreated'), watcherDisposable: testWatcher });
await azureFunctionService.createAzureFunction();
should(spy.notCalled).be.true('showErrorMessage should not have been called');
should(showErrorMessageSpy.notCalled).be.true('showErrorMessage should not have been called');
// set the connection info to be the one the user selects from list of databases quickpick
should(connectionInfo.database).equal('testDb');
should(connectionInfo.database).equal('testDb', 'connectionInfo.database should be testDb after user selects testDb');
});
it('Should create azure function project using command via the sql server table OE', async function (): Promise<void> {
@@ -104,7 +104,7 @@ describe('AzureFunctionsService', () => {
let connectionDetails = { options: connectionInfo };
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve('testConnectionString'));
const spy = sinon.spy(vscode.window, 'showErrorMessage');
const showErrorMessageSpy = sinon.spy(vscode.window, 'showErrorMessage');
// select input or output binding
let quickpickStub = sinon.stub(vscode.window, 'showQuickPick').resolves(<any>{ label: constants.input, type: BindingType.input });
@@ -118,12 +118,12 @@ describe('AzureFunctionsService', () => {
quickpickStub.onSecondCall().resolves(<any>{ label: constants.createNewLocalAppSettingWithIcon });
inputStub.onSecondCall().resolves('SqlConnectionString');
// promptConnectionStringPasswordAndUpdateConnectionString - tested in AzureFunctionUtils.test.ts
quickpickStub.onThirdCall().returns(Promise.resolve(constants.yesString) as any);
quickpickStub.onThirdCall().resolves((constants.yesString) as any);
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve('testConnectionString'));
// setLocalAppSetting with connection string setting name and connection string
// fails if we dont set writeFile stub
sinon.stub(fs.promises, 'writeFile');
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'SqlConnectionString', 'testConnectionString').returns(Promise.resolve(true));
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'SqlConnectionString', 'testConnectionString').resolves((true));
sinon.stub(utils, 'executeCommand').resolves('downloaded nuget package');
const testWatcher = TypeMoq.Mock.ofType<vscode.FileSystemWatcher>().object;
@@ -131,9 +131,9 @@ describe('AzureFunctionsService', () => {
await azureFunctionService.createAzureFunction(tableTestNode);
should(spy.notCalled).be.true('showErrorMessage should not have been called');
should(showErrorMessageSpy.notCalled).be.true('showErrorMessage should not have been called');
// set the connection info to be the one used from the test table node from OE
should(connectionInfo.database).equal('testDb');
should(connectionInfo.database).equal('testDb','connectionInfo.database should be testDb after user selects testDb');
});
it('Should open link to learn more about SQL bindings when no azure function project found in folder or workspace', async function (): Promise<void> {
@@ -145,8 +145,8 @@ describe('AzureFunctionsService', () => {
let connectionDetails = { options: connectionInfo };
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve('testConnectionString'));
const executeCommandSpy = sinon.stub(vscode.commands, 'executeCommand').withArgs(sinon.match.any, sinon.match.any).returns(Promise.resolve());
const showErrorStub = sinon.stub(vscode.window, 'showErrorMessage').returns(Promise.resolve(constants.learnMore) as any);
const executeCommandSpy = sinon.stub(vscode.commands, 'executeCommand').withArgs(sinon.match.any, sinon.match.any).resolves();
const showErrorStub = sinon.stub(vscode.window, 'showErrorMessage').resolves((constants.learnMore) as any);
await azureFunctionService.createAzureFunction();
should(executeCommandSpy.calledOnce).be.true('showErrorMessage should have been called');
@@ -163,10 +163,10 @@ describe('AzureFunctionsService', () => {
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve('testConnectionString'));
// error since no project file found in workspace or folder
const showErrorStub = sinon.stub(vscode.window, 'showErrorMessage').returns(Promise.resolve(constants.createProject) as any);
const showErrorStub = sinon.stub(vscode.window, 'showErrorMessage').resolves((constants.createProject) as any);
// user chooses to browse for folder
let quickpickStub = sinon.stub(vscode.window, 'showQuickPick').returns(Promise.resolve(constants.browseEllipsisWithIcon) as any);
let quickpickStub = sinon.stub(vscode.window, 'showQuickPick').resolves((constants.browseEllipsisWithIcon) as any);
// stub out folder to be chosen (showOpenDialog)
sinon.stub(vscode.window, 'showOpenDialog').withArgs(sinon.match.any).resolves([vscode.Uri.file(projectFilePath)]);
@@ -182,12 +182,12 @@ describe('AzureFunctionsService', () => {
quickpickStub.onThirdCall().resolves(<any>{ label: constants.createNewLocalAppSettingWithIcon });
inputStub.onSecondCall().resolves('SqlConnectionString');
// promptConnectionStringPasswordAndUpdateConnectionString - tested in AzureFunctionUtils.test.ts
quickpickStub.onCall(3).returns(Promise.resolve(constants.yesString) as any);
quickpickStub.onCall(3).resolves((constants.yesString) as any);
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve('testConnectionString'));
// setLocalAppSetting with connection string setting name and connection string
// fails if we dont set writeFile stub
sinon.stub(fs.promises, 'writeFile');
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'SqlConnectionString', 'testConnectionString').returns(Promise.resolve(true));
sinon.stub(azureFunctionUtils, 'setLocalAppSetting').withArgs(sinon.match.any, 'SqlConnectionString', 'testConnectionString').resolves((true));
sinon.stub(utils, 'executeCommand').resolves('downloaded nuget package');
const testWatcher = TypeMoq.Mock.ofType<vscode.FileSystemWatcher>().object;