From 2bcfcf4fb649771af1b421b183ab4c95cd3de2cd Mon Sep 17 00:00:00 2001 From: Stephen Weatherford Date: Tue, 5 Oct 2021 19:15:45 -0700 Subject: [PATCH] fix tests --- src/Bicep.Core.IntegrationTests/ScenarioTests.cs | 7 ++++--- .../Scenarios/ResourceListFunctionTests.cs | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs index 8f853c4841d..c437c3bce61 100644 --- a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs +++ b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs @@ -43,7 +43,7 @@ string randomString() { const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; return new string(Enumerable.Repeat(chars, generateRandomInt()) - .Select(s => s[generateRandomInt(0, s.Length-1)]).ToArray()); + .Select(s => s[generateRandomInt(0, s.Length - 1)]).ToArray()); } var file = "param adminuser string\nvar adminstring = 'xyx ${adminuser} 123'\n"; @@ -164,7 +164,8 @@ param serverFarmId string } "); - result.Should().NotHaveAnyDiagnostics(); + // Ignore outputs-should-not-contain-secrets warnings which are expected + result.Diagnostics.Where(d => d.Code != "outputs-should-not-contain-secrets").Should().BeEmpty(); result.Template.Should().HaveValueAtPath("$.outputs['config'].value", "[list(format('{0}/config/appsettings', resourceId('Microsoft.Web/sites', parameters('functionApp').name)), '2020-06-01')]"); } @@ -2590,7 +2591,7 @@ public void Test_Issue4212() ("BCP036", DiagnosticLevel.Error, "The property \"parent\" expected a value of type \"Microsoft.Network/virtualNetworks\" but the provided value is of type \"tenant\"."), }); } - + // https://github.com/Azure/bicep/issues/4542 [TestMethod] public void Test_Issue4542() diff --git a/src/Bicep.Core.IntegrationTests/Scenarios/ResourceListFunctionTests.cs b/src/Bicep.Core.IntegrationTests/Scenarios/ResourceListFunctionTests.cs index c8fb96c2f20..705bc5c6738 100644 --- a/src/Bicep.Core.IntegrationTests/Scenarios/ResourceListFunctionTests.cs +++ b/src/Bicep.Core.IntegrationTests/Scenarios/ResourceListFunctionTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Linq; using Bicep.Core.Diagnostics; using Bicep.Core.UnitTests.Assertions; using Bicep.Core.UnitTests.Utils; @@ -32,7 +33,8 @@ public void List_wildcard_function_on_resource_references() }) "); - result.Should().NotHaveAnyDiagnostics(); + // Ignore outputs-should-not-contain-secrets warnings which are expected + result.Diagnostics.Where(d => d.Code != "outputs-should-not-contain-secrets").Should().BeEmpty(); result.Template.Should().HaveValueAtPath("$.outputs['pkStandard'].value", "[listKeys(resourceId('Microsoft.Storage/storageAccounts', 'testacc'), '2019-06-01').keys[0].value]"); result.Template.Should().HaveValueAtPath("$.outputs['pkMethod'].value", "[listKeys(resourceId('Microsoft.Storage/storageAccounts', 'testacc'), '2019-06-01').keys[0].value]"); result.Template.Should().HaveValueAtPath("$.outputs['pkMethodVersionOverride'].value", "[listKeys(resourceId('Microsoft.Storage/storageAccounts', 'testacc'), '2021-01-01').keys[0].value]"); @@ -56,7 +58,8 @@ public void List_wildcard_function_on_cross_scope_resource_references() }) "); - result.Should().NotHaveAnyDiagnostics(); + // Ignore outputs-should-not-contain-secrets warnings which are expected + result.Diagnostics.Where(d => d.Code != "outputs-should-not-contain-secrets").Should().BeEmpty(); result.Template.Should().HaveValueAtPath("$.outputs['pkStandard'].value", "[listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'other'), 'Microsoft.Storage/storageAccounts', 'testacc'), '2019-06-01').keys[0].value]"); result.Template.Should().HaveValueAtPath("$.outputs['pkMethod'].value", "[listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'other'), 'Microsoft.Storage/storageAccounts', 'testacc'), '2019-06-01').keys[0].value]"); result.Template.Should().HaveValueAtPath("$.outputs['pkMethodVersionOverride'].value", "[listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'other'), 'Microsoft.Storage/storageAccounts', 'testacc'), '2021-01-01').keys[0].value]");