From a22801559b14b6c81e495817a22151b11fd9a0e2 Mon Sep 17 00:00:00 2001 From: Stephen Weatherford Date: Thu, 11 Nov 2021 10:55:52 -0800 Subject: [PATCH] fixes --- .../ServiceBus Queue.snippet.json | 8 +--- .../Storage Blob Container.snippet.json | 4 +- test/functional/snippets.test.ts | 36 ++++++++++++++- .../ServiceBus Namespace.snippetresult.json | 36 +++++++++++++++ .../ServiceBus Queue.snippetresult.json | 44 +++++++++++++++++++ .../Storage Blob Container.snippetresult.json | 34 ++++++++++++++ 6 files changed, 153 insertions(+), 9 deletions(-) create mode 100644 test/snippets/expected/ServiceBus Namespace.snippetresult.json create mode 100644 test/snippets/expected/ServiceBus Queue.snippetresult.json create mode 100644 test/snippets/expected/Storage Blob Container.snippetresult.json diff --git a/assets/resourceSnippets/ServiceBus Queue.snippet.json b/assets/resourceSnippets/ServiceBus Queue.snippet.json index af319d41f..40e8e9a33 100644 --- a/assets/resourceSnippets/ServiceBus Queue.snippet.json +++ b/assets/resourceSnippets/ServiceBus Queue.snippet.json @@ -14,15 +14,11 @@ "[resourceId('Microsoft.ServiceBus/namespaces', '${2:serviceBusQueue1}')]" ], "properties": { - "lockDuration": "${3||PT5M|PT30S|}", - "tier": /*${4|Premium,Standard|}*/ "Premium", - "tier": "${4|Premium,Standard|}", - "lockDuration": /*${5||PT5M|PT30S|}*/ "Prem", - "lockDuration": "${6||PT5M|PT30S|}", + "lockDuration": "${3|PT5M,PT30S|}", "maxSizeInMegabytes": 1024, "requiresDuplicateDetection": false, "requiresSession": false, - "defaultMessageTimeToLive": "${4|P14D|PT10M|P10675199DT2H48M5.4775807S|}", + "defaultMessageTimeToLive": "${4|P14D,PT10M,P10675199DT2H48M5.4775807S,(other)|}", "deadLetteringOnMessageExpiration": false, "duplicateDetectionHistoryTimeWindow": "PT10M", "maxDeliveryCount": 10, diff --git a/assets/resourceSnippets/Storage Blob Container.snippet.json b/assets/resourceSnippets/Storage Blob Container.snippet.json index e8cf3ed88..a51ff88cf 100644 --- a/assets/resourceSnippets/Storage Blob Container.snippet.json +++ b/assets/resourceSnippets/Storage Blob Container.snippet.json @@ -7,11 +7,11 @@ }, "resources": [ { - "name": "${1:accountName}/default/${1:blobContainerName}", + "name": "${1:accountName}/default/${2:blobContainerName}", "type": "Microsoft.Storage/storageAccounts/blobServices/containers", "apiVersion": "2021-04-01", "dependsOn": [ - "[resourceId('Microsoft.Storage/storageAccounts', '{1:accountName}')]" + "[resourceId('Microsoft.Storage/storageAccounts', '${1:accountName}')]" ], "properties": { "publicAccess": "None" diff --git a/test/functional/snippets.test.ts b/test/functional/snippets.test.ts index 3e93c3db3..9d9fb9c17 100644 --- a/test/functional/snippets.test.ts +++ b/test/functional/snippets.test.ts @@ -59,6 +59,34 @@ let resourceTemplate: string = `{ \t] }`; +let resourceTemplateWithLocation: string = `{ + \t"resources": [ + \t\t//Insert here: resource + \t], + \t"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + \t"contentVersion": "1.0.0.0", + \t"variables": { + \t\t//Insert here: variable + \t}, + \t"parameters": { + \t\t"location": { + \t\t\t"type": "string" + \t\t} + \t\t//Insert here: parameter + \t}, + \t"outputs": { + \t\t//Insert here: output + \t}, + \t"functions": [ + \t\t{ + \t\t\t"namespace": "udf", + \t\t\t"members": { + \t\t\t\t//Insert here: user function + \t\t\t} + \t\t} + \t] + }`; + let emptyTemplate: string = ` //Insert here: empty `; @@ -280,7 +308,13 @@ suite("Snippets functional tests", () => { validateSnippet(); - const template = overrideTemplateForSnippet[snippetName] !== undefined ? overrideTemplateForSnippet[snippetName] : resourceTemplate; + let defaultTemplate = resourceTemplate; + if (snippet.insertText.includes("parameters('location')")) { + // add location parameter if used in snippet + defaultTemplate = resourceTemplateWithLocation; + } + const template = overrideTemplateForSnippet[snippetName] !== undefined ? overrideTemplateForSnippet[snippetName] : defaultTemplate; + // tslint:disable-next-line: strict-boolean-expressions const expectedDiagnostics = (overrideExpectedDiagnostics[snippetName] || []).sort(); // tslint:disable-next-line: strict-boolean-expressions diff --git a/test/snippets/expected/ServiceBus Namespace.snippetresult.json b/test/snippets/expected/ServiceBus Namespace.snippetresult.json new file mode 100644 index 000000000..78d9a313e --- /dev/null +++ b/test/snippets/expected/ServiceBus Namespace.snippetresult.json @@ -0,0 +1,36 @@ +{ + "resources": [ + { + "name": "serviceBusNamespace1", + "type": "Microsoft.ServiceBus/namespaces", + "apiVersion": "2021-01-01-preview", + "location": "[parameters('location')]", + "sku": { + "name": "Standard" + }, + "properties": {} + } + ], + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "variables": { + //Insert here: variable + }, + "parameters": { + "location": { + "type": "string" + } + //Insert here: parameter + }, + "outputs": { + //Insert here: output + }, + "functions": [ + { + "namespace": "udf", + "members": { + //Insert here: user function + } + } + ] +} \ No newline at end of file diff --git a/test/snippets/expected/ServiceBus Queue.snippetresult.json b/test/snippets/expected/ServiceBus Queue.snippetresult.json new file mode 100644 index 000000000..1701c368a --- /dev/null +++ b/test/snippets/expected/ServiceBus Queue.snippetresult.json @@ -0,0 +1,44 @@ +{ + "resources": [ + { + "name": "serviceBusNamespace1/serviceBusQueue1", + "type": "Microsoft.ServiceBus/namespaces/queues", + "apiVersion": "2021-01-01-preview", + "dependsOn": [ + "[resourceId('Microsoft.ServiceBus/namespaces', 'serviceBusQueue1')]" + ], + "properties": { + "lockDuration": "PT5M", + "maxSizeInMegabytes": 1024, + "requiresDuplicateDetection": false, + "requiresSession": false, + "defaultMessageTimeToLive": "P14D", + "deadLetteringOnMessageExpiration": false, + "duplicateDetectionHistoryTimeWindow": "PT10M", + "maxDeliveryCount": 10, + "autoDeleteOnIdle": "P10675199DT2H48M5.4775807S", + "enablePartitioning": false, + "enableExpress": false + } + } + ], + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "variables": { + //Insert here: variable + }, + "parameters": { + //Insert here: parameter + }, + "outputs": { + //Insert here: output + }, + "functions": [ + { + "namespace": "udf", + "members": { + //Insert here: user function + } + } + ] +} \ No newline at end of file diff --git a/test/snippets/expected/Storage Blob Container.snippetresult.json b/test/snippets/expected/Storage Blob Container.snippetresult.json new file mode 100644 index 000000000..07c570cb2 --- /dev/null +++ b/test/snippets/expected/Storage Blob Container.snippetresult.json @@ -0,0 +1,34 @@ +{ + "resources": [ + { + "name": "accountName/default/blobContainerName", + "type": "Microsoft.Storage/storageAccounts/blobServices/containers", + "apiVersion": "2021-04-01", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts', 'accountName')]" + ], + "properties": { + "publicAccess": "None" + } + } + ], + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "variables": { + //Insert here: variable + }, + "parameters": { + //Insert here: parameter + }, + "outputs": { + //Insert here: output + }, + "functions": [ + { + "namespace": "udf", + "members": { + //Insert here: user function + } + } + ] +}