Add SQL Bindings Tests / Vbump (#19717)

* add further testing

* vbump version

* add successfully test

* address comments
This commit is contained in:
Vasu Bhog
2022-06-14 14:47:36 -07:00
committed by GitHub
parent ba82444229
commit 6ab09d9b1b
8 changed files with 384 additions and 70 deletions

View File

@@ -36,7 +36,7 @@ export interface IFileFunctionObject {
* @returns settings in local.settings.json. If no settings are found, returns default "empty" settings
*/
export async function getLocalSettingsJson(localSettingsPath: string): Promise<ILocalSettingsJson> {
if (fs.existsSync(localSettingsPath)) {
if (await utils.exists(localSettingsPath)) {
const data: string = (fs.readFileSync(localSettingsPath)).toString();
try {
return JSON.parse(data);
@@ -281,7 +281,7 @@ export async function getAFProjectContainingFile(fileUri: vscode.Uri): Promise<v
// Use 'host.json' as an indicator that this is a functions project
// copied from verifyIsproject.ts in vscode-azurefunctions extension
export async function isFunctionProject(folderPath: string): Promise<boolean> {
return fs.existsSync(path.join(folderPath, constants.hostFileName));
return await utils.exists(path.join(folderPath, constants.hostFileName));
}
/**
@@ -359,7 +359,6 @@ export async function promptForObjectName(bindingType: BindingType, connectionIn
*/
export async function promptAndUpdateConnectionStringSetting(projectUri: vscode.Uri | undefined, connectionInfo?: IConnectionInfo): Promise<IConnectionStringInfo | undefined> {
let connectionStringSettingName: string | undefined;
const vscodeMssqlApi = await utils.getVscodeMssqlApi();
// show the settings from project's local.settings.json if there's an AF functions project
if (projectUri) {
@@ -494,6 +493,7 @@ export async function promptAndUpdateConnectionStringSetting(projectUri: vscode.
}
} else {
// Let user choose from existing connections to create connection string from
const vscodeMssqlApi = await utils.getVscodeMssqlApi();
connectionInfo = await vscodeMssqlApi.promptForConnection(true);
}
}

View File

@@ -116,7 +116,9 @@ export async function getUniqueFileName(fileName: string, folderPath?: string):
let uniqueFileName = fileName;
while (count < maxCount) {
if (!fs.existsSync(path.join(folderPath, uniqueFileName + '.cs'))) {
// checks to see if file exists
let uniqueFilePath = path.join(folderPath, uniqueFileName + '.cs');
if (!(await exists(uniqueFilePath))) {
return uniqueFileName;
}
count += 1;
@@ -173,3 +175,12 @@ export function getErrorType(error: any): string | undefined {
return 'UnknownError';
}
}
export async function exists(path: string): Promise<boolean> {
try {
await fs.promises.access(path);
return true;
} catch (e) {
return false;
}
}