Skip to content

Commit

Permalink
21122.7 validation assembly (#1199)
Browse files Browse the repository at this point in the history
* 21122.7 validation assembly

* Add test

* Add 1185 test

Co-authored-by: Stephen Weatherford <[email protected]>
  • Loading branch information
StephenWeatherford and Stephen Weatherford authored Feb 23, 2021
1 parent 9b94b16 commit ab22441
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "0.15.0-alpha1",
"publisher": "msazurermtools",
"config": {
"ARM_LANGUAGE_SERVER_NUGET_VERSION": "3.0.0-preview.21113.1"
"ARM_LANGUAGE_SERVER_NUGET_VERSION": "3.0.0-preview.21122.7"
},
"categories": [
"Azure",
Expand Down
85 changes: 41 additions & 44 deletions test/LinkedTemplates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,58 +75,55 @@ suite("Linked templates regressions", () => {
// TODO: For some reason, these two tests are failing consistently in the
// Windows build pipeline, but not locally or on other platforms.
if (!isWin32) {

// tslint:disable-next-line: no-suspicious-comment
/* TODO: Regressed by https://github.com/microsoft/vscode-azurearmtools/issues/1185
testWithLanguageServer("Nested template wrong param type", async () => {
await testDiagnostics(
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2019-10-01",
"name": "inner",
"properties": {
"expressionEvaluationOptions": {
"scope": "inner"
},
"mode": "Incremental",
testWithLanguageServer("Nested template wrong param type", async () => {
await testDiagnostics(
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2019-10-01",
"name": "inner",
"properties": {
"expressionEvaluationOptions": {
"scope": "inner"
},
"mode": "Incremental",
"parameters": {
"parameter1": {
"value": 123
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"parameter1": {
"value": 123
"type": "string"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"parameter1": {
"type": "string"
}
},
"resources": []
}
"resources": []
}
}
]
},
{
includeRange: true,
parameters: {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
}
}
},
[
"Error: Template validation failed: Template parameter JToken type is not valid. Expected 'String, Uri'. Actual 'Integer'. Please see https://aka.ms/arm-deploy/#parameter-file for usage details. (arm-template (validation)) [9,21-9,21] [The error occurred in a nested template near here] [13,19-13,19]",
"Warning: The parameter 'parameter1' is never used. (arm-template (expressions)) [23,13-23,25]"
]
);
});*/
},
{
includeRange: true,
parameters: {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
}
}
},
[
"Error: Template validation failed: Template parameter JToken type is not valid. Expected 'String, Uri'. Actual 'Integer'. Please see https://aka.ms/arm-deploy/#parameter-file for usage details. (arm-template (validation)) [9,21-9,21] [The error occurred in a nested template near here] [23,21-23,21]",
"Warning: The parameter 'parameter1' is never used. (arm-template (expressions)) [23,13-23,25]"
]
);
});

testWithLanguageServer("Nested template missing properties", async () => {
await testDiagnostics(
Expand Down
27 changes: 27 additions & 0 deletions test/functional/linkedTemplates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,4 +533,31 @@ suite("Linked templates functional tests", () => {
}
);
}

// tslint:disable-next-line: no-suspicious-comment
// TODO: Hangs on build machine?
if (!isWin32) {
createLinkedTemplateTest(
"tc14",
"Incorrect content version specified",
{
mainTemplateFile: "templates/linkedTemplates/tc14-contentVersion/<TC>.json",
mainParametersFile: "<TC>.parameters.json",
mainTemplateExpected: [
// tslint:disable-next-line: no-suspicious-comment
// TODO: See 1144 - line/col in the additional info location is incorrect
"Error: Template validation failed: The content version contained in the template '1.2.3.4' does not match the content version found in the deployment object's TemplateLink property '1.2.3.5'. Please see https://aka.ms/arm-deploy for usage details. (arm-template (validation)) [40,27] [The error occurred in a linked template near here] [40,27]",
],
waitForDiagnosticSubstring: "The content version", // needed?
linkedTemplates: [
{
parentTemplateFile: "templates/linkedTemplates/tc14-contentVersion/<TC>.json",
linkedTemplateFile: "templates/linkedTemplates/tc14-contentVersion/subfolder/child14.json",
expected: [
]
}
]
}
);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.2.3.4",
"resources": []
}
53 changes: 53 additions & 0 deletions test/templates/linkedTemplates/tc14-contentVersion/tc14.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
// Verify correct scope of expressions, variables, parameters

"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "linkedDeployment1",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "subfolder/child14.json",
// correct content version - OK
"contentVersion": "1.2.3.4"
},
"parameters": {
}
}
},
{
"name": "linkedDeployment1",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "subfolder/child14.json"
// no content version - OK
},
"parameters": {
}
}
},
{
"name": "linkedDeployment1",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "subfolder/child14.json",
// incorrect content version - ERROR
"contentVersion": "1.2.3.5"
},
"parameters": {
}
}
}
],
"outputs": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
}
}

0 comments on commit ab22441

Please sign in to comment.