|
|
|
|
@@ -28,13 +28,17 @@ const mockAccount: AzureAccount = {
|
|
|
|
|
properties: {
|
|
|
|
|
providerSettings: settings[0].metadata,
|
|
|
|
|
isMsAccount: true,
|
|
|
|
|
owningTenant: {
|
|
|
|
|
id: 'tenantId',
|
|
|
|
|
displayName: 'tenantDisplayName',
|
|
|
|
|
},
|
|
|
|
|
tenants: []
|
|
|
|
|
},
|
|
|
|
|
isStale: false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const mockTenantId: string = 'mock_tenant';
|
|
|
|
|
const mockSubscriptionId ='mock_subscription';
|
|
|
|
|
const mockSubscriptionId = 'mock_subscription';
|
|
|
|
|
|
|
|
|
|
const mockSubscription: azureResource.AzureResourceSubscription = {
|
|
|
|
|
id: mockSubscriptionId,
|
|
|
|
|
@@ -50,7 +54,7 @@ let mockResourceProvider2: TypeMoq.IMock<azureResource.IAzureResourceProvider>;
|
|
|
|
|
|
|
|
|
|
let resourceService: AzureResourceService;
|
|
|
|
|
|
|
|
|
|
describe('AzureResourceService.listResourceProviderIds', function(): void {
|
|
|
|
|
describe('AzureResourceService.listResourceProviderIds', function (): void {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
mockResourceTreeDataProvider1 = TypeMoq.Mock.ofType<azureResource.IAzureResourceTreeDataProvider>();
|
|
|
|
|
mockResourceTreeDataProvider1.setup((o) => o.getRootChildren()).returns(() => Promise.resolve([TypeMoq.Mock.ofType<azdata.TreeItem>().object]));
|
|
|
|
|
@@ -71,7 +75,7 @@ describe('AzureResourceService.listResourceProviderIds', function(): void {
|
|
|
|
|
resourceService.areResourceProvidersLoaded = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Should be correct when registering providers.', async function(): Promise<void> {
|
|
|
|
|
it('Should be correct when registering providers.', async function (): Promise<void> {
|
|
|
|
|
resourceService.registerResourceProvider(mockResourceProvider1.object);
|
|
|
|
|
let providerIds = await resourceService.listResourceProviderIds();
|
|
|
|
|
should(providerIds).Array();
|
|
|
|
|
@@ -87,7 +91,7 @@ describe('AzureResourceService.listResourceProviderIds', function(): void {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('AzureResourceService.getRootChildren', function(): void {
|
|
|
|
|
describe('AzureResourceService.getRootChildren', function (): void {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
mockResourceTreeDataProvider1 = TypeMoq.Mock.ofType<azureResource.IAzureResourceTreeDataProvider>();
|
|
|
|
|
mockResourceTreeDataProvider1.setup((o) => o.getRootChildren()).returns(() => Promise.resolve([TypeMoq.Mock.ofType<azdata.TreeItem>().object]));
|
|
|
|
|
@@ -101,13 +105,13 @@ describe('AzureResourceService.getRootChildren', function(): void {
|
|
|
|
|
resourceService.areResourceProvidersLoaded = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Should be correct when provider id is correct.', async function(): Promise<void> {
|
|
|
|
|
it('Should be correct when provider id is correct.', async function (): Promise<void> {
|
|
|
|
|
const children = await resourceService.getRootChildren(mockResourceProvider1.object.providerId, mockAccount, mockSubscription, mockTenantId);
|
|
|
|
|
|
|
|
|
|
should(children).Array();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Should throw exceptions when provider id is incorrect.', async function(): Promise<void> {
|
|
|
|
|
it('Should throw exceptions when provider id is incorrect.', async function (): Promise<void> {
|
|
|
|
|
const providerId = 'non_existent_provider_id';
|
|
|
|
|
try {
|
|
|
|
|
await resourceService.getRootChildren(providerId, mockAccount, mockSubscription, mockTenantId);
|
|
|
|
|
@@ -120,7 +124,7 @@ describe('AzureResourceService.getRootChildren', function(): void {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('AzureResourceService.getChildren', function(): void {
|
|
|
|
|
describe('AzureResourceService.getChildren', function (): void {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
mockResourceTreeDataProvider1 = TypeMoq.Mock.ofType<azureResource.IAzureResourceTreeDataProvider>();
|
|
|
|
|
mockResourceTreeDataProvider1.setup((o) => o.getRootChildren()).returns(() => Promise.resolve([TypeMoq.Mock.ofType<azdata.TreeItem>().object]));
|
|
|
|
|
@@ -135,12 +139,12 @@ describe('AzureResourceService.getChildren', function(): void {
|
|
|
|
|
resourceService.areResourceProvidersLoaded = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Should be correct when provider id is correct.', async function(): Promise<void> {
|
|
|
|
|
it('Should be correct when provider id is correct.', async function (): Promise<void> {
|
|
|
|
|
const children = await resourceService.getChildren(mockResourceProvider1.object.providerId, TypeMoq.It.isAny());
|
|
|
|
|
should(children).Array();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Should throw exceptions when provider id is incorrect.', async function(): Promise<void> {
|
|
|
|
|
it('Should throw exceptions when provider id is incorrect.', async function (): Promise<void> {
|
|
|
|
|
const providerId = 'non_existent_provider_id';
|
|
|
|
|
try {
|
|
|
|
|
await resourceService.getRootChildren(providerId, mockAccount, mockSubscription, mockTenantId);
|
|
|
|
|
@@ -153,7 +157,7 @@ describe('AzureResourceService.getChildren', function(): void {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('AzureResourceService.getTreeItem', function(): void {
|
|
|
|
|
describe('AzureResourceService.getTreeItem', function (): void {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
mockResourceTreeDataProvider1 = TypeMoq.Mock.ofType<azureResource.IAzureResourceTreeDataProvider>();
|
|
|
|
|
mockResourceTreeDataProvider1.setup((o) => o.getRootChildren()).returns(() => Promise.resolve([TypeMoq.Mock.ofType<azdata.TreeItem>().object]));
|
|
|
|
|
@@ -168,12 +172,12 @@ describe('AzureResourceService.getTreeItem', function(): void {
|
|
|
|
|
resourceService.areResourceProvidersLoaded = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Should be correct when provider id is correct.', async function(): Promise<void> {
|
|
|
|
|
it('Should be correct when provider id is correct.', async function (): Promise<void> {
|
|
|
|
|
const treeItem = await resourceService.getTreeItem(mockResourceProvider1.object.providerId, TypeMoq.It.isAny());
|
|
|
|
|
should(treeItem).Object();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Should throw exceptions when provider id is incorrect.', async function(): Promise<void> {
|
|
|
|
|
it('Should throw exceptions when provider id is incorrect.', async function (): Promise<void> {
|
|
|
|
|
const providerId = 'non_existent_provider_id';
|
|
|
|
|
try {
|
|
|
|
|
await resourceService.getRootChildren(providerId, mockAccount, mockSubscription, mockTenantId);
|
|
|
|
|
|