Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Weatherford committed Nov 11, 2021
1 parent 742952e commit a228015
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 9 deletions.
8 changes: 2 additions & 6 deletions assets/resourceSnippets/ServiceBus Queue.snippet.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions assets/resourceSnippets/Storage Blob Container.snippet.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
36 changes: 35 additions & 1 deletion test/functional/snippets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
`;
Expand Down Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions test/snippets/expected/ServiceBus Namespace.snippetresult.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
44 changes: 44 additions & 0 deletions test/snippets/expected/ServiceBus Queue.snippetresult.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
34 changes: 34 additions & 0 deletions test/snippets/expected/Storage Blob Container.snippetresult.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}

0 comments on commit a228015

Please sign in to comment.