import { ResourceManagementClient } from '@azure/arm-resources' ; import { IHookCallbackContext , ISuiteCallbackContext } from 'mocha' ; import * as vscode from 'vscode' ; import { ISubscriptionContext , TestAzureAccount } from 'vscode-azureextensiondev' ; import { AzExtTreeDataProvider , AzureParentTreeItem } from 'vscode-azureextensionui' ; import { AzureAccountTreeItem , ext , treeUtils } from '../extension.bundle' ; import { longRunningTestsEnabled } from './global.test' ; suite ( 'Create Azure Resources' , async function ( this ) : Promise < void > { this . timeout ( 1200 * 1000 ) ; const resourceGroupsToDelete = [ ] ; const testAccount = new TestAzureAccount ( vscode ) ; suiteSetup ( async function ( this ) : Promise < void > { if ( ! longRunningTestsEnabled ) { this . skip ( ) ; } this . timeout ( 120 * 1000 ) ; await testAccount . signIn ( ) ; ext . azureAccountTreeItem = new AzureAccountTreeItem ( testAccount ) ; ext . tree = new AzExtTreeDataProvider ( ext . azureAccountTreeItem , 'azureApiManagement.LoadMore' ) ; const rootNode = await treeUtils . getRootNode ( ext . tree ) ; rootNode . root . userId = "vscodeapimtest@microsoft.com" ; } ) ; suiteTeardown ( async function ( this ) : Promise < void > { if ( ! longRunningTestsEnabled ) { this . skip ( ) ; } this . timeout ( 1200 * 1000 ) ; const client = getResourceManagementClient ( testAccount ) ; for ( const resourceGroup of resourceGroupsToDelete ) { if ( await client . resourceGroups . checkExistence ( resourceGroup ) !== undefined ) { console . log ( `Deleting resource group "${ resourceGroup }"...` ) ; await client . resourceGroups . deleteMethod ( resourceGroup ) ; console . log ( `Resource group "${ resourceGroup }" deleted.` ) ; } else { console . log ( `Ignoring resource group "${ resourceGroup }" because it does not exist.` ) ; } } ext . azureAccountTreeItem . dispose ( ) ; } ) ; } ) ; function getResourceManagementClient ( testAccount ) { const subscriptionContext = testAccount . getSubscriptionContext ( ) ; return new ResourceManagementClient ( subscriptionContext . credentials , subscriptionContext . subscriptionId ) ; }