From f35576ae7feda959561e19fab76ee838bf4d66f8 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Thu, 2 Sep 2021 09:20:32 -0700 Subject: [PATCH] Enable no-floating-promises for azurecore (#16946) * Enable no-floating-promises for azurecore * few more * fix compile --- extensions/azurecore/.eslintrc.json | 13 ++++++++++ .../src/account-provider/auths/azureAuth.ts | 6 ++--- .../account-provider/azureAccountProvider.ts | 6 ++--- .../azureAccountProviderService.ts | 6 ++--- .../azurecore/src/azureResource/commands.ts | 24 +++++++++---------- .../azurecore/src/azureResource/interfaces.ts | 2 +- .../azureResource/services/cacheService.ts | 4 ++-- .../services/subscriptionFilterService.ts | 2 +- .../services/subscriptionService.ts | 2 +- .../azureResource/services/terminalService.ts | 6 ++--- .../src/azureResource/tree/accountTreeNode.ts | 6 ++--- .../src/azureResource/tree/baseTreeNodes.ts | 4 ++-- .../tree/connectionDialogTreeProvider.ts | 4 ++-- .../azureResource/tree/flatAccountTreeNode.ts | 6 ++--- .../azureResource/tree/flatTreeProvider.ts | 2 +- extensions/azurecore/src/extension.ts | 4 ++-- .../utils/simpleWebServer.test.ts | 4 ++-- .../tree/accountTreeNode.test.ts | 16 ++++++++++--- package.json | 2 +- 19 files changed, 71 insertions(+), 48 deletions(-) create mode 100644 extensions/azurecore/.eslintrc.json diff --git a/extensions/azurecore/.eslintrc.json b/extensions/azurecore/.eslintrc.json new file mode 100644 index 0000000000..17c0ebcd6f --- /dev/null +++ b/extensions/azurecore/.eslintrc.json @@ -0,0 +1,13 @@ +{ + "parserOptions": { + "project": "./extensions/azurecore/tsconfig.json" + }, + "rules": { + "@typescript-eslint/no-floating-promises": [ + "error", + { + "ignoreVoid": true + } + ] + } +} diff --git a/extensions/azurecore/src/account-provider/auths/azureAuth.ts b/extensions/azurecore/src/account-provider/auths/azureAuth.ts index 0287e101bb..b543da4222 100644 --- a/extensions/azurecore/src/account-provider/auths/azureAuth.ts +++ b/extensions/azurecore/src/account-provider/auths/azureAuth.ts @@ -104,7 +104,7 @@ export abstract class AzureAuth implements vscode.Disposable { if (loginComplete) { loginComplete.reject(ex); } else { - vscode.window.showErrorMessage(ex.getPrintableString()); + void vscode.window.showErrorMessage(ex.getPrintableString()); } } Logger.error(ex); @@ -139,7 +139,7 @@ export abstract class AzureAuth implements vscode.Disposable { return await this.hydrateAccount(tokenResult, this.getTokenClaims(tokenResult.token)); } catch (ex) { if (ex instanceof AzureAuthError) { - vscode.window.showErrorMessage(ex.getPrintableString()); + void vscode.window.showErrorMessage(ex.getPrintableString()); } Logger.error(ex); account.isStale = true; @@ -616,7 +616,7 @@ export abstract class AzureAuth implements vscode.Disposable { return this.deleteAccountCache(account); } catch (ex) { const msg = localize('azure.cacheErrrorRemove', "Error when removing your account from the cache."); - vscode.window.showErrorMessage(msg); + void vscode.window.showErrorMessage(msg); Logger.error('Error when removing tokens.', ex); } } diff --git a/extensions/azurecore/src/account-provider/azureAccountProvider.ts b/extensions/azurecore/src/account-provider/azureAccountProvider.ts index 5bd38b9858..2915c24ed9 100644 --- a/extensions/azurecore/src/account-provider/azureAccountProvider.ts +++ b/extensions/azurecore/src/account-provider/azureAccountProvider.ts @@ -119,7 +119,7 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp } private async _getSecurityToken(account: AzureAccount, resource: azdata.AzureResource): Promise { - vscode.window.showInformationMessage(localize('azure.deprecatedGetSecurityToken', "A call was made to azdata.accounts.getSecurityToken, this method is deprecated and will be removed in future releases. Please use getAccountSecurityToken instead.")); + void vscode.window.showInformationMessage(localize('azure.deprecatedGetSecurityToken', "A call was made to azdata.accounts.getSecurityToken, this method is deprecated and will be removed in future releases. Please use getAccountSecurityToken instead.")); const azureAccount = account as AzureAccount; const response: MultiTenantTokenResponse = {}; for (const tenant of azureAccount.properties.tenants) { @@ -147,7 +147,7 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp if (this.authMappings.size === 0) { Logger.log('No auth method was enabled.'); - vscode.window.showErrorMessage(noAuthAvailable); + void vscode.window.showErrorMessage(noAuthAvailable); return { canceled: true }; } @@ -164,7 +164,7 @@ export class AzureAccountProvider implements azdata.AccountProvider, vscode.Disp if (!pick) { Logger.log('No auth method was selected.'); - vscode.window.showErrorMessage(noAuthSelected); + void vscode.window.showErrorMessage(noAuthSelected); return { canceled: true }; } diff --git a/extensions/azurecore/src/account-provider/azureAccountProviderService.ts b/extensions/azurecore/src/account-provider/azureAccountProviderService.ts index e9500dd0c6..ce5554027f 100644 --- a/extensions/azurecore/src/account-provider/azureAccountProviderService.ts +++ b/extensions/azurecore/src/account-provider/azureAccountProviderService.ts @@ -58,7 +58,7 @@ export class AzureAccountProviderService implements vscode.Disposable { AzureAccountProviderService.CommandClearTokenCache, () => { self._event.emit(AzureAccountProviderService.CommandClearTokenCache); } )); - this._event.on(AzureAccountProviderService.CommandClearTokenCache, () => { self.onClearTokenCache(); }); + this._event.on(AzureAccountProviderService.CommandClearTokenCache, () => { void self.onClearTokenCache(); }); // 1) Get a credential provider // 2a) Store the credential provider for use later @@ -98,11 +98,11 @@ export class AzureAccountProviderService implements vscode.Disposable { .then( () => { let message = localize('clearTokenCacheSuccess', "Token cache successfully cleared"); - vscode.window.showInformationMessage(`${loc.extensionName}: ${message}`); + void vscode.window.showInformationMessage(`${loc.extensionName}: ${message}`); }, err => { let message = localize('clearTokenCacheFailure', "Failed to clear token cache"); - vscode.window.showErrorMessage(`${loc.extensionName}: ${message}: ${err}`); + void vscode.window.showErrorMessage(`${loc.extensionName}: ${message}: ${err}`); }); } diff --git a/extensions/azurecore/src/azureResource/commands.ts b/extensions/azurecore/src/azureResource/commands.ts index 72943b11f4..6104695924 100644 --- a/extensions/azurecore/src/azureResource/commands.ts +++ b/extensions/azurecore/src/azureResource/commands.ts @@ -27,7 +27,7 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT const enablePreviewFeatures = vscode.workspace.getConfiguration('workbench').get('enablePreviewFeatures'); if (!enablePreviewFeatures) { const msg = localize('azure.cloudTerminalPreview', "You must enable preview features in order to use Azure Cloud Shell."); - vscode.window.showInformationMessage(msg); + void vscode.window.showInformationMessage(msg); return; } let azureAccount: AzureAccount | undefined; @@ -41,7 +41,7 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT const action = await vscode.window.showErrorMessage(localize('azure.noAccountError', "You are not currently signed into any Azure accounts, Please sign in and then try again."), signin); if (action === signin) { - vscode.commands.executeCommand('azure.resource.signin'); + void vscode.commands.executeCommand('azure.resource.signin'); } return; } else if (accounts.length === 1) { @@ -52,7 +52,7 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT placeHolder: localize('azure.pickAnAzureAccount', "Select an Azure account") }); if (!pickedAccount) { - vscode.window.showErrorMessage(localize('azure.accountNotSelectedError', "You must select an Azure account for this feature to work.")); + void vscode.window.showErrorMessage(localize('azure.accountNotSelectedError', "You must select an Azure account for this feature to work.")); return; } azureAccount = accounts.find(acct => acct.displayInfo.displayName === pickedAccount); @@ -64,7 +64,7 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT const listOfTenants = azureAccount.properties.tenants.map(t => t.displayName); if (listOfTenants.length === 0) { - vscode.window.showErrorMessage(localize('azure.noTenants', "A tenant is required for this feature. Your Azure subscription seems to have no tenants.")); + void vscode.window.showErrorMessage(localize('azure.noTenants', "A tenant is required for this feature. Your Azure subscription seems to have no tenants.")); return; } @@ -78,7 +78,7 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT const pickedTenant = await vscode.window.showQuickPick(listOfTenants, { canPickMany: false }); if (!pickedTenant) { - vscode.window.showErrorMessage(localize('azure.mustPickTenant', "You must select a tenant for this feature to work.")); + void vscode.window.showErrorMessage(localize('azure.mustPickTenant', "You must select a tenant for this feature to work.")); return; } @@ -89,7 +89,7 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT await terminalService.getOrCreateCloudConsole(azureAccount, tenant); } catch (ex) { console.error(ex); - vscode.window.showErrorMessage(ex); + void vscode.window.showErrorMessage(ex); } }); @@ -114,7 +114,7 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT subscriptions = await subscriptionService.getSubscriptions(account); } catch (error) { account.isStale = true; - vscode.window.showErrorMessage(AzureResourceErrorMessageUtil.getErrorMessage(error)); + void vscode.window.showErrorMessage(AzureResourceErrorMessageUtil.getErrorMessage(error)); return; } } @@ -162,15 +162,15 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT }); vscode.commands.registerCommand('azure.resource.azureview.refresh', async (node?: TreeNode) => { - await azureViewTree.refresh(node, true); + return azureViewTree.refresh(node, true); }); vscode.commands.registerCommand('azure.resource.connectiondialog.refresh', async (node?: TreeNode) => { - await connectionDialogTree.refresh(node, true); + return connectionDialogTree.refresh(node, true); }); vscode.commands.registerCommand('azure.resource.signin', async (node?: TreeNode) => { - vscode.commands.executeCommand('workbench.actions.modal.linkedAccount'); + return vscode.commands.executeCommand('workbench.actions.modal.linkedAccount'); }); vscode.commands.registerCommand('azure.resource.connectsqlserver', async (node?: TreeNode | azdata.ObjectExplorerContext) => { @@ -191,7 +191,7 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT const conn = await azdata.connection.openConnectionDialog(undefined, connectionProfile, { saveConnection: true, showDashboard: true }); if (conn) { - vscode.commands.executeCommand('workbench.view.connections'); + void vscode.commands.executeCommand('workbench.view.connections'); } }); @@ -205,6 +205,6 @@ export function registerAzureResourceCommands(appContext: AppContext, azureViewT } const urlToOpen = `${connectionProfile.azurePortalEndpoint}//${connectionProfile.azureTenantId}/#resource/${connectionProfile.azureResourceId}`; - vscode.env.openExternal(vscode.Uri.parse(urlToOpen)); + await vscode.env.openExternal(vscode.Uri.parse(urlToOpen)); }); } diff --git a/extensions/azurecore/src/azureResource/interfaces.ts b/extensions/azurecore/src/azureResource/interfaces.ts index 3a9cb68df0..3478227db0 100644 --- a/extensions/azurecore/src/azureResource/interfaces.ts +++ b/extensions/azurecore/src/azureResource/interfaces.ts @@ -33,7 +33,7 @@ export interface IAzureResourceCacheService { get(key: string): T | undefined; - update(key: string, value: T): void; + update(key: string, value: T): Promise; } diff --git a/extensions/azurecore/src/azureResource/services/cacheService.ts b/extensions/azurecore/src/azureResource/services/cacheService.ts index ef523c5429..af3d2b69ed 100644 --- a/extensions/azurecore/src/azureResource/services/cacheService.ts +++ b/extensions/azurecore/src/azureResource/services/cacheService.ts @@ -22,8 +22,8 @@ export class AzureResourceCacheService implements IAzureResourceCacheService { return this._context.workspaceState.get(key); } - public update(key: string, value: T): void { - this._context.workspaceState.update(key, value); + public async update(key: string, value: T): Promise { + await this._context.workspaceState.update(key, value); } private _context: ExtensionContext = undefined; diff --git a/extensions/azurecore/src/azureResource/services/subscriptionFilterService.ts b/extensions/azurecore/src/azureResource/services/subscriptionFilterService.ts index 680f3ab646..06695f6219 100644 --- a/extensions/azurecore/src/azureResource/services/subscriptionFilterService.ts +++ b/extensions/azurecore/src/azureResource/services/subscriptionFilterService.ts @@ -45,7 +45,7 @@ export class AzureResourceSubscriptionFilterService implements IAzureResourceSub selectedSubscriptionsCache[account.key.accountId] = selectedSubscriptions; - this._cacheService.update(this._cacheKey, { selectedSubscriptions: selectedSubscriptionsCache }); + await this._cacheService.update(this._cacheKey, { selectedSubscriptions: selectedSubscriptionsCache }); const filters: string[] = []; for (const accountId in selectedSubscriptionsCache) { diff --git a/extensions/azurecore/src/azureResource/services/subscriptionService.ts b/extensions/azurecore/src/azureResource/services/subscriptionService.ts index 000fe93efa..b08a4742c5 100644 --- a/extensions/azurecore/src/azureResource/services/subscriptionService.ts +++ b/extensions/azurecore/src/azureResource/services/subscriptionService.ts @@ -47,7 +47,7 @@ export class AzureResourceSubscriptionService implements IAzureResourceSubscript const errorMsg = localize('azure.resource.tenantSubscriptionsError', "Failed to get subscriptions for account {0} (tenant '{1}'). {2}", account.key.accountId, tenantId, AzureResourceErrorMessageUtil.getErrorMessage(error)); console.warn(errorMsg); errors.push(error); - vscode.window.showWarningMessage(errorMsg); + void vscode.window.showWarningMessage(errorMsg); } } if (!gotSubscriptions) { diff --git a/extensions/azurecore/src/azureResource/services/terminalService.ts b/extensions/azurecore/src/azureResource/services/terminalService.ts index f0fec8af8a..1c84c39dde 100644 --- a/extensions/azurecore/src/azureResource/services/terminalService.ts +++ b/extensions/azurecore/src/azureResource/services/terminalService.ts @@ -37,7 +37,7 @@ const handleNeverUsed = async (): Promise => { const option = await vscode.window.showInformationMessage(neverUsedString, openAzureShellButton, okButton); if (option.action === TerminalOption.OPEN_SITE) { - vscode.env.openExternal(vscode.Uri.parse('https://aka.ms/AA83f8f')); + void vscode.env.openExternal(vscode.Uri.parse('https://aka.ms/AA83f8f')); } }; @@ -115,7 +115,7 @@ export class AzureTerminalService implements IAzureTerminalService { }); if (!shell) { - vscode.window.showErrorMessage(localize('azure.shellTypeRequired', "You must pick a shell type")); + void vscode.window.showErrorMessage(localize('azure.shellTypeRequired', "You must pick a shell type")); return; } @@ -236,7 +236,7 @@ class AzureTerminal implements vscode.Pseudoterminal { const terminalUri = terminalResult.data?.socketUri; if (terminalResult.data.error) { - vscode.window.showErrorMessage(terminalResult.data.error.message); + void vscode.window.showErrorMessage(terminalResult.data.error.message); } if (!terminalUri) { diff --git a/extensions/azurecore/src/azureResource/tree/accountTreeNode.ts b/extensions/azurecore/src/azureResource/tree/accountTreeNode.ts index 0a69a4e3bb..a6b6a54514 100644 --- a/extensions/azurecore/src/azureResource/tree/accountTreeNode.ts +++ b/extensions/azurecore/src/azureResource/tree/accountTreeNode.ts @@ -44,7 +44,7 @@ export class AzureResourceAccountTreeNode extends AzureResourceContainerTreeNode if (this._isClearingCache) { subscriptions = await this._subscriptionService.getSubscriptions(this.account); - this.updateCache(subscriptions); + await this.updateCache(subscriptions); this._isClearingCache = false; } else { subscriptions = await this.getCachedSubscriptions(); @@ -77,7 +77,7 @@ export class AzureResourceAccountTreeNode extends AzureResourceContainerTreeNode errMsg = AzureResourceErrorMessageUtil.getErrorMessage(err); } if (!token) { - vscode.window.showWarningMessage(localize('azure.unableToAccessSubscription', "Unable to access subscription {0} ({1}). Please [refresh the account](command:azure.resource.signin) to try again. {2}", s.name, s.id, errMsg)); + void vscode.window.showWarningMessage(localize('azure.unableToAccessSubscription', "Unable to access subscription {0} ({1}). Please [refresh the account](command:azure.resource.signin) to try again. {2}", s.name, s.id, errMsg)); return false; } return true; @@ -91,7 +91,7 @@ export class AzureResourceAccountTreeNode extends AzureResourceContainerTreeNode } } catch (error) { if (error instanceof AzureSubscriptionError) { - vscode.commands.executeCommand('azure.resource.signin'); + void vscode.commands.executeCommand('azure.resource.signin'); } return [AzureResourceMessageTreeNode.create(AzureResourceErrorMessageUtil.getErrorMessage(error), this)]; } diff --git a/extensions/azurecore/src/azureResource/tree/baseTreeNodes.ts b/extensions/azurecore/src/azureResource/tree/baseTreeNodes.ts index c17bc3950b..76df0955f0 100644 --- a/extensions/azurecore/src/azureResource/tree/baseTreeNodes.ts +++ b/extensions/azurecore/src/azureResource/tree/baseTreeNodes.ts @@ -45,8 +45,8 @@ export abstract class AzureResourceContainerTreeNodeBase extends AzureResourceTr this._cacheKey = this._cacheService.generateKey(id); } - protected updateCache(cache: T): void { - this._cacheService.update(this._cacheKey, cache); + protected updateCache(cache: T): Promise { + return this._cacheService.update(this._cacheKey, cache); } protected getCache(): T { diff --git a/extensions/azurecore/src/azureResource/tree/connectionDialogTreeProvider.ts b/extensions/azurecore/src/azureResource/tree/connectionDialogTreeProvider.ts index 5bf8636614..8645d97088 100644 --- a/extensions/azurecore/src/azureResource/tree/connectionDialogTreeProvider.ts +++ b/extensions/azurecore/src/azureResource/tree/connectionDialogTreeProvider.ts @@ -70,9 +70,9 @@ export class ConnectionDialogTreeProvider implements vscode.TreeDataProvider 0) { const showAccountsAction = localize('azure.resource.tree.treeProvider.openAccountsDialog', "Show Azure accounts"); - vscode.window.showErrorMessage(localize('azure.resource.tree.treeProvider.accountLoadError', "Failed to load some Azure accounts. {0}", errorMessages.join(',')), showAccountsAction).then(result => { + void vscode.window.showErrorMessage(localize('azure.resource.tree.treeProvider.accountLoadError', "Failed to load some Azure accounts. {0}", errorMessages.join(',')), showAccountsAction).then(result => { if (result === showAccountsAction) { - vscode.commands.executeCommand('azure.resource.signin'); + void vscode.commands.executeCommand('azure.resource.signin'); } }); } diff --git a/extensions/azurecore/src/azureResource/tree/flatAccountTreeNode.ts b/extensions/azurecore/src/azureResource/tree/flatAccountTreeNode.ts index 12ace17f1c..f603648fa8 100644 --- a/extensions/azurecore/src/azureResource/tree/flatAccountTreeNode.ts +++ b/extensions/azurecore/src/azureResource/tree/flatAccountTreeNode.ts @@ -68,7 +68,7 @@ export class FlatAccountTreeNode extends AzureResourceContainerTreeNodeBase { public async getChildren(): Promise { if (this._isClearingCache) { - this._loader.start(); + this._loader.start().catch(err => console.error('Error loading Azure FlatAccountTreeNodes ', err)); this._isClearingCache = false; return []; } else { @@ -211,12 +211,12 @@ class FlatAccountTreeNodeLoader { } } catch (error) { if (error instanceof AzureSubscriptionError) { - vscode.commands.executeCommand('azure.resource.signin'); + void vscode.commands.executeCommand('azure.resource.signin'); } // http status code 429 means "too many requests" // use a custom error message for azure resource graph api throttling error to make it more actionable for users. const errorMessage = error?.statusCode === 429 ? localize('azure.resource.throttleerror', "Requests from this account have been throttled. To retry, please select a smaller number of subscriptions.") : AzureResourceErrorMessageUtil.getErrorMessage(error); - vscode.window.showErrorMessage(localize('azure.resource.tree.loadresourceerror', "An error occurred while loading Azure resources: {0}", errorMessage)); + void vscode.window.showErrorMessage(localize('azure.resource.tree.loadresourceerror', "An error occurred while loading Azure resources: {0}", errorMessage)); } this._isLoading = false; diff --git a/extensions/azurecore/src/azureResource/tree/flatTreeProvider.ts b/extensions/azurecore/src/azureResource/tree/flatTreeProvider.ts index cb535cb744..11396aba16 100644 --- a/extensions/azurecore/src/azureResource/tree/flatTreeProvider.ts +++ b/extensions/azurecore/src/azureResource/tree/flatTreeProvider.ts @@ -40,7 +40,7 @@ export class FlatAzureResourceTreeProvider implements vscode.TreeDataProvider console.error('Error loading Azure Resources for FlatAzureResourceTreeProvider ', err)); return [AzureResourceMessageTreeNode.create(localize('azure.resource.tree.treeProvider.loadingLabel', "Loading ..."), undefined)]; } diff --git a/extensions/azurecore/src/extension.ts b/extensions/azurecore/src/extension.ts index 1ae3db21dd..5103481061 100644 --- a/extensions/azurecore/src/extension.ts +++ b/extensions/azurecore/src/extension.ts @@ -104,7 +104,7 @@ export async function activate(context: vscode.ExtensionContext): Promise console.error('Error registering Azure ResourceDeployment value provider ', err)); return { getSubscriptions(account?: azurecore.AzureAccount, ignoreErrors?: boolean, selectedOnly: boolean = false): Promise { diff --git a/extensions/azurecore/src/test/account-provider/utils/simpleWebServer.test.ts b/extensions/azurecore/src/test/account-provider/utils/simpleWebServer.test.ts index 9103e564c7..2bf99fedc8 100644 --- a/extensions/azurecore/src/test/account-provider/utils/simpleWebServer.test.ts +++ b/extensions/azurecore/src/test/account-provider/utils/simpleWebServer.test.ts @@ -24,7 +24,7 @@ describe('AccountProvider.SimpleWebServer', function (): void { it('Double startup should fail', async function (): Promise { await server.startup(); - server.startup().should.be.rejected(); + await server.startup().should.be.rejected(); }); it('404 on unknown requests', async function (): Promise { @@ -59,7 +59,7 @@ describe('AccountProvider.SimpleWebServer', function (): void { it('Server shuts off', async function (): Promise { await server.startup(); - server.shutdown().should.not.be.rejected(); + await server.shutdown().should.not.be.rejected(); }); }); diff --git a/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts b/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts index 423dbc699a..b1e0bf95bd 100644 --- a/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts +++ b/extensions/azurecore/src/test/azureResource/tree/accountTreeNode.test.ts @@ -109,7 +109,10 @@ describe('AzureResourceAccountTreeNode.info', function (): void { mockCacheService.setup((o) => o.generateKey(TypeMoq.It.isAnyString())).returns(() => generateGuid()); mockCacheService.setup((o) => o.get(TypeMoq.It.isAnyString())).returns(() => mockSubscriptionCache); - mockCacheService.setup((o) => o.update(TypeMoq.It.isAnyString(), TypeMoq.It.isAny())).returns(() => mockSubscriptionCache = mockSubscriptions); + mockCacheService.setup((o) => o.update(TypeMoq.It.isAnyString(), TypeMoq.It.isAny())).returns(() => { + mockSubscriptionCache = mockSubscriptions; + return Promise.resolve(); + }); }); afterEach(function (): void { @@ -217,7 +220,10 @@ describe('AzureResourceAccountTreeNode.getChildren', function (): void { sinon.stub(azdata.accounts, 'getAccountSecurityToken').resolves(mockToken); mockCacheService.setup((o) => o.generateKey(TypeMoq.It.isAnyString())).returns(() => generateGuid()); mockCacheService.setup((o) => o.get(TypeMoq.It.isAnyString())).returns(() => mockSubscriptionCache); - mockCacheService.setup((o) => o.update(TypeMoq.It.isAnyString(), TypeMoq.It.isAny())).returns(() => mockSubscriptionCache = mockSubscriptions); + mockCacheService.setup((o) => o.update(TypeMoq.It.isAnyString(), TypeMoq.It.isAny())).returns(() => { + mockSubscriptionCache = mockSubscriptions; + return Promise.resolve(); + }); }); afterEach(function (): void { @@ -354,7 +360,11 @@ describe('AzureResourceAccountTreeNode.clearCache', function (): void { sinon.stub(azdata.accounts, 'getAccountSecurityToken').returns(Promise.resolve(mockToken)); mockCacheService.setup((o) => o.generateKey(TypeMoq.It.isAnyString())).returns(() => generateGuid()); mockCacheService.setup((o) => o.get(TypeMoq.It.isAnyString())).returns(() => mockSubscriptionCache); - mockCacheService.setup((o) => o.update(TypeMoq.It.isAnyString(), TypeMoq.It.isAny())).returns(() => mockSubscriptionCache = mockSubscriptions); + mockCacheService.setup((o) => o.update(TypeMoq.It.isAnyString(), TypeMoq.It.isAny())).returns(() => + { + mockSubscriptionCache = mockSubscriptions; + return Promise.resolve(); + }); }); afterEach(function (): void { diff --git a/package.json b/package.json index 77e527aaf3..08ebd2a231 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "core-ci": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js core-ci", "extensions-ci": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js extensions-ci", "sqllint": "eslint --no-eslintrc -c .eslintrc.sql.ts.json --rulesdir ./build/lib/eslint --ext .ts ./src/sql", - "extensions-lint": "eslint --rulesdir ./build/lib/eslint --ext .ts ./extensions" + "extensions-lint": "eslint --rulesdir ./build/lib/eslint --ext .ts ./extensions/azurecore" }, "dependencies": { "@angular/animations": "~4.1.3",