mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -05:00
Connection management service updates to support multiple providers (#9698)
* Connection management service work * Fix tests * Change how accounts are deleted * Be consistent with names * feedback * Fix based on feedback * Change sqltoolsservice version
This commit is contained in:
@@ -20,7 +20,7 @@ export class AccountPickerViewModel {
|
||||
public selectedAccount: azdata.Account | undefined;
|
||||
|
||||
constructor(
|
||||
private _providerId: string,
|
||||
_providerId: string,
|
||||
@IAccountManagementService private _accountManagementService: IAccountManagementService
|
||||
) {
|
||||
// Create our event emitters
|
||||
@@ -37,7 +37,7 @@ export class AccountPickerViewModel {
|
||||
*/
|
||||
public initialize(): Thenable<azdata.Account[]> {
|
||||
// Load a baseline of the accounts for the provider
|
||||
return this._accountManagementService.getAccountsForProvider(this._providerId)
|
||||
return this._accountManagementService.getAccounts()
|
||||
.then(undefined, () => {
|
||||
// In the event we failed to lookup accounts for the provider, just send
|
||||
// back an empty collection
|
||||
|
||||
@@ -47,6 +47,7 @@ export default class AccountStore implements IAccountStore {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public remove(key: azdata.AccountKey): Thenable<boolean> {
|
||||
return this.doOperation(() => {
|
||||
return this.readFromMemento()
|
||||
|
||||
@@ -20,8 +20,10 @@ export interface IAccountManagementService {
|
||||
addAccount(providerId: string): Thenable<void>;
|
||||
getAccountProviderMetadata(): Thenable<azdata.AccountProviderMetadata[]>;
|
||||
getAccountsForProvider(providerId: string): Thenable<azdata.Account[]>;
|
||||
getAccounts(): Thenable<azdata.Account[]>;
|
||||
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{ [key: string]: { token: string } }>;
|
||||
removeAccount(accountKey: azdata.AccountKey): Thenable<boolean>;
|
||||
removeAccounts(): Thenable<boolean>;
|
||||
refreshAccount(account: azdata.Account): Thenable<azdata.Account>;
|
||||
|
||||
// UI METHODS //////////////////////////////////////////////////////////
|
||||
|
||||
@@ -85,7 +85,7 @@ suite('Account picker view model tests', () => {
|
||||
evUpdateAccounts.assertNotFired();
|
||||
|
||||
// ... The account management service should have been called
|
||||
mockAccountManagementService.verify(x => x.getAccountsForProvider(TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
mockAccountManagementService.verify(x => x.getAccounts(), TypeMoq.Times.once());
|
||||
|
||||
// ... The results that were returned should be an array of account
|
||||
assert.ok(Array.isArray(results));
|
||||
@@ -108,7 +108,7 @@ suite('Account picker view model tests', () => {
|
||||
evUpdateAccounts.assertNotFired();
|
||||
|
||||
// ... The account management service should have been called
|
||||
mockAccountManagementService.verify(x => x.getAccountsForProvider(TypeMoq.It.isAny()), TypeMoq.Times.once());
|
||||
mockAccountManagementService.verify(x => x.getAccounts(), TypeMoq.Times.once());
|
||||
|
||||
// ... The results should be an empty array
|
||||
assert.ok(Array.isArray(result));
|
||||
@@ -124,6 +124,8 @@ function getMockAccountManagementService(resolveProviders: boolean, resolveAccou
|
||||
.returns(() => resolveProviders ? Promise.resolve(providers) : Promise.reject(null).then());
|
||||
mockAccountManagementService.setup(x => x.getAccountsForProvider(TypeMoq.It.isAny()))
|
||||
.returns(() => resolveAccounts ? Promise.resolve(accounts) : Promise.reject(null).then());
|
||||
mockAccountManagementService.setup(x => x.getAccounts())
|
||||
.returns(() => resolveAccounts ? Promise.resolve(accounts) : Promise.reject(null).then());
|
||||
|
||||
mockAccountManagementService.setup(x => x.updateAccountListEvent)
|
||||
.returns(() => mockUpdateAccountEmitter.event);
|
||||
|
||||
@@ -43,6 +43,10 @@ export class TestAccountManagementService implements IAccountManagementService {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
getAccounts(): Thenable<azdata.Account[]> {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
getAccountsForProvider(providerId: string): Thenable<azdata.Account[]> {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
@@ -55,6 +59,10 @@ export class TestAccountManagementService implements IAccountManagementService {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
removeAccounts(): Thenable<boolean> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
refreshAccount(account: azdata.Account): Thenable<azdata.Account> {
|
||||
throw new Error('Method not implemented');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user