[SQL Bindings] Skip prompt to select setting from connection settings if there is none (#19798)

* add no setting option

* add tests

* reformat tests
This commit is contained in:
Vasu Bhog
2022-06-27 12:31:46 -07:00
committed by GitHub
parent fae67b4485
commit d5da934572
5 changed files with 455 additions and 113 deletions

View File

@@ -26,6 +26,7 @@ describe('AzureFunctionsService', () => {
beforeEach(function (): void {
testUtils = createTestUtils();
});
describe('Create Azure Function with SQL Binding', () => {
it('Should show info message to install azure functions extension if not installed', async function (): Promise<void> {
const infoStub = sinon.stub(vscode.window, 'showInformationMessage').resolves(undefined);
@@ -41,7 +42,14 @@ describe('AzureFunctionsService', () => {
sinon.stub(azureFunctionUtils, 'getAzureFunctionProject').resolves(projectFilePath); //set azure function project to have one project
sinon.stub(utils, 'getVscodeMssqlApi').resolves(testUtils.vscodeMssqlIExtension.object);
let connectionInfo: IConnectionInfo = createTestCredentials();// create test connectionInfo
// create fake connection string settings for local.setting.json to be used
sinon.stub(fs.promises, 'access').onFirstCall().resolves();
sinon.stub(fs, 'readFileSync').withArgs(sinon.match.any).returns(
`{"IsEncrypted": false,
"Values": {"test1": "test1", "test2": "test2", "test3":"test3"}}`
);
let connectionInfo: IConnectionInfo = createTestCredentials(); // create test connectionInfo
let connectionDetails = { options: connectionInfo };
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve('testConnectionString'));
@@ -96,6 +104,13 @@ describe('AzureFunctionsService', () => {
sinon.stub(azureFunctionUtils, 'getAzureFunctionProject').resolves(projectFilePath); //set azure function project to have one project
sinon.stub(utils, 'getVscodeMssqlApi').resolves(testUtils.vscodeMssqlIExtension.object);
// create fake connection string settings for local.setting.json to be used
sinon.stub(fs.promises, 'access').onFirstCall().resolves();
sinon.stub(fs, 'readFileSync').withArgs(sinon.match.any).returns(
`{"IsEncrypted": false,
"Values": {"test1": "test1", "test2": "test2", "test3":"test3"}}`
);
let connectionInfo: IConnectionInfo = createTestCredentials();// create test connectionInfo
let connectionDetails = { options: connectionInfo };
testUtils.vscodeMssqlIExtension.setup(x => x.getConnectionString(connectionDetails, true, false)).returns(() => Promise.resolve('testConnectionString'));