Created
May 10, 2019 00:09
-
-
Save bsiegel/c47af8347ad96a9be53eb28b06a268dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/sdk/servicebus/service-bus/test/testUtils.ts b/sdk/servicebus/service-bus/test/testUtils.ts | |
| index dbc74573..4fe78608 100644 | |
| --- a/sdk/servicebus/service-bus/test/testUtils.ts | |
| +++ b/sdk/servicebus/service-bus/test/testUtils.ts | |
| @@ -194,54 +194,42 @@ export function getEnvVars(): { [key: string]: string } { | |
| async function recreateQueue(queueName: string, parameters: SBQueue): Promise<void> { | |
| const env = getEnvVars(); | |
| - await msRestNodeAuth | |
| - .loginWithServicePrincipalSecret(env.clientId, env.clientSecret, env.tenantId) | |
| - .then(async (creds) => { | |
| - const client = await new ServiceBusManagementClient(creds, env.subscriptionId); | |
| - await client.queues.deleteMethod( | |
| - env.resourceGroup, | |
| - env.servicebusNamespace, | |
| - queueName, | |
| - function(error: any): void { | |
| - if (error) throw error.message; | |
| - } | |
| - ); | |
| - await client.queues.createOrUpdate( | |
| - env.resourceGroup, | |
| - env.servicebusNamespace, | |
| - queueName, | |
| - parameters, | |
| - function(error: any): void { | |
| - if (error) throw error.message; | |
| - } | |
| - ); | |
| - }); | |
| + const creds = await msRestNodeAuth | |
| + .loginWithServicePrincipalSecret(env.clientId, env.clientSecret, env.tenantId); | |
| + const client = await new ServiceBusManagementClient(creds, env.subscriptionId); | |
| + await client.queues.deleteMethod( | |
| + env.resourceGroup, | |
| + env.servicebusNamespace, | |
| + queueName, | |
| + err => { if (err) throw err.message; } | |
| + ); | |
| + await client.queues.createOrUpdate( | |
| + env.resourceGroup, | |
| + env.servicebusNamespace, | |
| + queueName, | |
| + parameters, | |
| + err => { if (err) throw err.message; } | |
| + ); | |
| } | |
| async function recreateTopic(topicName: string, parameters: SBTopic): Promise<void> { | |
| const env = getEnvVars(); | |
| - await msRestNodeAuth | |
| - .loginWithServicePrincipalSecret(env.clientId, env.clientSecret, env.tenantId) | |
| - .then(async (creds) => { | |
| - const client = await new ServiceBusManagementClient(creds, env.subscriptionId); | |
| - await client.topics.deleteMethod( | |
| - env.resourceGroup, | |
| - env.servicebusNamespace, | |
| - topicName, | |
| - function(error: any): void { | |
| - if (error) throw error.message; | |
| - } | |
| - ); | |
| - await client.topics.createOrUpdate( | |
| - env.resourceGroup, | |
| - env.servicebusNamespace, | |
| - topicName, | |
| - parameters, | |
| - function(error: any): void { | |
| - if (error) throw error.message; | |
| - } | |
| - ); | |
| - }); | |
| + const creds = await msRestNodeAuth | |
| + .loginWithServicePrincipalSecret(env.clientId, env.clientSecret, env.tenantId); | |
| + const client = await new ServiceBusManagementClient(creds, env.subscriptionId); | |
| + await client.topics.deleteMethod( | |
| + env.resourceGroup, | |
| + env.servicebusNamespace, | |
| + topicName, | |
| + err => { if (err) throw err.message; } | |
| + ); | |
| + await client.topics.createOrUpdate( | |
| + env.resourceGroup, | |
| + env.servicebusNamespace, | |
| + topicName, | |
| + parameters, | |
| + err => { if (err) throw err.message; } | |
| + ); | |
| } | |
| async function recreateSubscription( | |
| @@ -250,26 +238,22 @@ async function recreateSubscription( | |
| parameters: SBSubscription | |
| ): Promise<void> { | |
| const env = getEnvVars(); | |
| - await msRestNodeAuth | |
| - .loginWithServicePrincipalSecret(env.clientId, env.clientSecret, env.tenantId) | |
| - .then(async (creds) => { | |
| - const client = await new ServiceBusManagementClient(creds, env.subscriptionId); | |
| - /* | |
| - Unlike Queues/Topics, there is no need to delete the subscription because | |
| - `recreateTopic` is called before `recreateSubscription` which would | |
| - delete the topic and the subscriptions before creating a new topic. | |
| - */ | |
| - await client.subscriptions.createOrUpdate( | |
| - env.resourceGroup, | |
| - env.servicebusNamespace, | |
| - topicName, | |
| - subscriptionName, | |
| - parameters, | |
| - function(error: any): void { | |
| - if (error) throw error.message; | |
| - } | |
| - ); | |
| - }); | |
| + const creds = await msRestNodeAuth | |
| + .loginWithServicePrincipalSecret(env.clientId, env.clientSecret, env.tenantId); | |
| + const client = await new ServiceBusManagementClient(creds, env.subscriptionId); | |
| + /* | |
| + Unlike Queues/Topics, there is no need to delete the subscription because | |
| + `recreateTopic` is called before `recreateSubscription` which would | |
| + delete the topic and the subscriptions before creating a new topic. | |
| + */ | |
| + await client.subscriptions.createOrUpdate( | |
| + env.resourceGroup, | |
| + env.servicebusNamespace, | |
| + topicName, | |
| + subscriptionName, | |
| + parameters, | |
| + err => { if (err) throw err.message; } | |
| + ); | |
| } | |
| export async function getTopicClientWithTwoSubscriptionClients( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment