mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 17:23:21 -05:00
More dangling promise cleanup (#8518)
* More dangling promise cleanup * return void * Function to async * Fix a couple missed promises
This commit is contained in:
@@ -214,35 +214,32 @@ suite('SQL ConnectionManagementService tests', () => {
|
||||
|
||||
}
|
||||
|
||||
function connect(uri: string, options?: IConnectionCompletionOptions, fromDialog?: boolean, connection?: IConnectionProfile, error?: string, errorCode?: number, errorCallStack?: string): Promise<IConnectionResult> {
|
||||
async function connect(uri: string, options?: IConnectionCompletionOptions, fromDialog?: boolean, connection?: IConnectionProfile, error?: string, errorCode?: number, errorCallStack?: string): Promise<IConnectionResult> {
|
||||
let connectionToUse = connection ? connection : connectionProfile;
|
||||
return new Promise<IConnectionResult>((resolve, reject) => {
|
||||
let id = connectionToUse.getOptionsKey();
|
||||
let defaultUri = 'connection:' + (id ? id : connectionToUse.serverName + ':' + connectionToUse.databaseName);
|
||||
connectionManagementService.onConnectionRequestSent(() => {
|
||||
let info: azdata.ConnectionInfoSummary = {
|
||||
connectionId: error ? undefined : 'id',
|
||||
connectionSummary: {
|
||||
databaseName: connectionToUse.databaseName,
|
||||
serverName: connectionToUse.serverName,
|
||||
userName: connectionToUse.userName
|
||||
},
|
||||
errorMessage: error,
|
||||
errorNumber: errorCode,
|
||||
messages: errorCallStack,
|
||||
ownerUri: uri ? uri : defaultUri,
|
||||
serverInfo: undefined
|
||||
};
|
||||
connectionManagementService.onConnectionComplete(0, info);
|
||||
});
|
||||
connectionManagementService.cancelConnectionForUri(uri).then(() => {
|
||||
if (fromDialog) {
|
||||
resolve(connectionManagementService.connectAndSaveProfile(connectionToUse, uri, options));
|
||||
} else {
|
||||
resolve(connectionManagementService.connect(connectionToUse, uri, options));
|
||||
}
|
||||
});
|
||||
let id = connectionToUse.getOptionsKey();
|
||||
let defaultUri = 'connection:' + (id ? id : connectionToUse.serverName + ':' + connectionToUse.databaseName);
|
||||
connectionManagementService.onConnectionRequestSent(() => {
|
||||
let info: azdata.ConnectionInfoSummary = {
|
||||
connectionId: error ? undefined : 'id',
|
||||
connectionSummary: {
|
||||
databaseName: connectionToUse.databaseName,
|
||||
serverName: connectionToUse.serverName,
|
||||
userName: connectionToUse.userName
|
||||
},
|
||||
errorMessage: error,
|
||||
errorNumber: errorCode,
|
||||
messages: errorCallStack,
|
||||
ownerUri: uri ? uri : defaultUri,
|
||||
serverInfo: undefined
|
||||
};
|
||||
connectionManagementService.onConnectionComplete(0, info);
|
||||
});
|
||||
await connectionManagementService.cancelConnectionForUri(uri);
|
||||
if (fromDialog) {
|
||||
return connectionManagementService.connectAndSaveProfile(connectionToUse, uri, options);
|
||||
} else {
|
||||
return connectionManagementService.connect(connectionToUse, uri, options);
|
||||
}
|
||||
}
|
||||
|
||||
test('showConnectionDialog should open the dialog with default type given no parameters', done => {
|
||||
|
||||
Reference in New Issue
Block a user