Finish strict null azurecore (#20619)

* Finish strict null azurecore

* one last
This commit is contained in:
Charles Gagnon
2022-09-19 14:29:42 -07:00
committed by GitHub
parent c6f3996ec7
commit dd253b4e98
8 changed files with 46 additions and 46 deletions

View File

@@ -14,6 +14,7 @@ import { AppContext } from '../../appContext';
import { AzureResourceServiceNames } from '../../azureResource/constants';
import settings from '../../account-provider/providerSettings';
import { AzureAccount, azureResource } from 'azurecore';
import { TreeNode } from '../../azureResource/treeNode';
// Mock test data
const mockAccount: AzureAccount = {
@@ -107,7 +108,7 @@ describe('AzureResourceResourceTreeNode.info', function (): void {
resourceService.registerResourceProvider(mockResourceProvider.object);
resourceService.areResourceProvidersLoaded = true;
appContext = new AppContext(undefined);
appContext = new AppContext(TypeMoq.Mock.ofType<vscode.ExtensionContext>().object);
appContext.registerService(AzureResourceServiceNames.resourceService, resourceService);
});
@@ -115,7 +116,7 @@ describe('AzureResourceResourceTreeNode.info', function (): void {
const resourceTreeNode = new AzureResourceResourceTreeNode({
resourceProviderId: mockResourceProviderId,
resourceNode: mockResourceRootNode
}, undefined, appContext);
}, TypeMoq.Mock.ofType<TreeNode>().object, appContext);
should(resourceTreeNode.nodePathValue).equal(mockResourceRootNode.treeItem.id);
@@ -147,7 +148,7 @@ describe('AzureResourceResourceTreeNode.getChildren', function (): void {
resourceService.registerResourceProvider(mockResourceProvider.object);
resourceService.areResourceProvidersLoaded = true;
appContext = new AppContext(undefined);
appContext = new AppContext(TypeMoq.Mock.ofType<vscode.ExtensionContext>().object);
appContext.registerService(AzureResourceServiceNames.resourceService, resourceService);
});
@@ -156,7 +157,7 @@ describe('AzureResourceResourceTreeNode.getChildren', function (): void {
resourceProviderId: mockResourceProviderId,
resourceNode: mockResourceRootNode
},
undefined, appContext);
TypeMoq.Mock.ofType<TreeNode>().object, appContext);
const children = await resourceTreeNode.getChildren();
@@ -186,7 +187,7 @@ describe('AzureResourceResourceTreeNode.getChildren', function (): void {
const resourceTreeNode = new AzureResourceResourceTreeNode({
resourceProviderId: mockResourceProviderId,
resourceNode: mockResourceNode1
}, undefined, appContext);
}, TypeMoq.Mock.ofType<TreeNode>().object, appContext);
const children = await resourceTreeNode.getChildren();

View File

@@ -23,8 +23,8 @@ describe('AzureResourceAccountNotSignedInTreeNode.info', function(): void {
should(treeItem.contextValue).equal(AzureResourceItemType.message);
should(treeItem.collapsibleState).equal(vscode.TreeItemCollapsibleState.None);
should(treeItem.command).not.undefined();
should(treeItem.command.title).equal(label);
should(treeItem.command.command).equal('azure.resource.signin');
should(treeItem.command?.title).equal(label);
should(treeItem.command?.command).equal('azure.resource.signin');
const nodeInfo = treeNode.getNodeInfo();
should(nodeInfo.isLeaf).true();

View File

@@ -141,7 +141,7 @@ describe('AzureResourceAccountTreeNode.info', function (): void {
it('Should be correct when there are subscriptions listed.', async function (): Promise<void> {
mockSubscriptionService.setup((o) => o.getSubscriptions(mockAccount, TypeMoq.It.isAny())).returns(() => Promise.resolve(mockSubscriptions));
mockSubscriptionFilterService.setup((o) => o.getSelectedSubscriptions(mockAccount)).returns(() => Promise.resolve(undefined));
mockSubscriptionFilterService.setup((o) => o.getSelectedSubscriptions(mockAccount)).returns(() => Promise.resolve([]));
sinon.stub(azdata.accounts, 'getAccountSecurityToken').resolves(mockToken);
const accountTreeNodeLabel = `${mockAccount.displayInfo.displayName} (${mockSubscriptions.length} / ${mockSubscriptions.length} subscriptions)`;
@@ -265,7 +265,7 @@ describe('AzureResourceAccountTreeNode.getChildren', function (): void {
it('Should load subscriptions from cache when it is not clearing cache.', async function (): Promise<void> {
mockSubscriptionService.setup((o) => o.getSubscriptions(mockAccount, TypeMoq.It.isAny())).returns(() => Promise.resolve(mockSubscriptions));
mockSubscriptionFilterService.setup((o) => o.getSelectedSubscriptions(mockAccount)).returns(() => Promise.resolve(undefined));
mockSubscriptionFilterService.setup((o) => o.getSelectedSubscriptions(mockAccount)).returns(() => Promise.resolve([]));
const accountTreeNode = new AzureResourceAccountTreeNode(mockAccount, mockAppContext, mockTreeChangeHandler.object);

View File

@@ -17,7 +17,8 @@ import { AzureResourceService } from '../../../azureResource/resourceService';
import { AzureResourceResourceTreeNode } from '../../../azureResource/resourceTreeNode';
import { IAzureResourceCacheService } from '../../../azureResource/interfaces';
import { generateGuid } from '../../../azureResource/utils';
import { AzureAccount, azureResource } from 'azurecore';
import { AzureAccount, AzureAccountProperties, azureResource } from 'azurecore';
import { TreeNode } from '../../../azureResource/treeNode';
// Mock services
let appContext: AppContext;
@@ -39,7 +40,7 @@ const mockAccount: AzureAccount = {
contextualDisplayName: 'test',
userId: 'test@email.com'
},
properties: undefined,
properties: TypeMoq.Mock.ofType<AzureAccountProperties>().object,
isStale: false
};
@@ -95,7 +96,7 @@ describe('AzureResourceSubscriptionTreeNode.info', function(): void {
});
it('Should be correct when created.', async function(): Promise<void> {
const subscriptionTreeNode = new AzureResourceSubscriptionTreeNode(mockAccount, mockSubscription, mockTenantId, appContext, mockTreeChangeHandler.object, undefined);
const subscriptionTreeNode = new AzureResourceSubscriptionTreeNode(mockAccount, mockSubscription, mockTenantId, appContext, mockTreeChangeHandler.object, TypeMoq.Mock.ofType<TreeNode>().object);
should(subscriptionTreeNode.nodePathValue).equal(`account_${mockAccount.key.accountId}.subscription_${mockSubscription.id}.tenant_${mockTenantId}`);
@@ -148,7 +149,7 @@ describe('AzureResourceSubscriptionTreeNode.getChildren', function(): void {
});
it('Should return resource containers.', async function(): Promise<void> {
const subscriptionTreeNode = new AzureResourceSubscriptionTreeNode(mockAccount, mockSubscription, mockTenantId, appContext, mockTreeChangeHandler.object, undefined);
const subscriptionTreeNode = new AzureResourceSubscriptionTreeNode(mockAccount, mockSubscription, mockTenantId, appContext, mockTreeChangeHandler.object, TypeMoq.Mock.ofType<TreeNode>().object);
const children = await subscriptionTreeNode.getChildren();
mockResourceTreeDataProvider1.verify((o) => o.getRootChildren(), TypeMoq.Times.once());

View File

@@ -17,7 +17,7 @@ import { AzureResourceAccountTreeNode } from '../../../azureResource/tree/accoun
import { AzureResourceAccountNotSignedInTreeNode } from '../../../azureResource/tree/accountNotSignedInTreeNode';
import { AzureResourceServiceNames } from '../../../azureResource/constants';
import { generateGuid } from '../../../azureResource/utils';
import { AzureAccount } from 'azurecore';
import { AzureAccount, AzureAccountProperties } from 'azurecore';
// Mock services
let mockAppContext: AppContext;
@@ -37,7 +37,7 @@ const mockAccount1: AzureAccount = {
contextualDisplayName: 'test',
userId: 'test@email.com'
},
properties: undefined,
properties: TypeMoq.Mock.ofType<AzureAccountProperties>().object,
isStale: false
};
const mockAccount2: AzureAccount = {
@@ -51,7 +51,7 @@ const mockAccount2: AzureAccount = {
contextualDisplayName: 'test',
userId: 'test@email.com'
},
properties: undefined,
properties: TypeMoq.Mock.ofType<AzureAccountProperties>().object,
isStale: false
};
const mockAccounts = [mockAccount1, mockAccount2];
@@ -94,7 +94,7 @@ describe('AzureResourceTreeProvider.getChildren', function (): void {
});
it('Should handle when there is no accounts.', async function (): Promise<void> {
sinon.stub(azdata.accounts, 'getAllAccounts').returns(Promise.resolve(undefined));
sinon.stub(azdata.accounts, 'getAllAccounts').returns(Promise.resolve([]));
const treeProvider = new AzureResourceTreeProvider(mockAppContext);
treeProvider.isSystemInitialized = true;