diff --git a/src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.ARM.tests.ps1 b/src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.ARM.tests.ps1 index 77643c3d..b11e048f 100644 --- a/src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.ARM.tests.ps1 +++ b/src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.ARM.tests.ps1 @@ -6,6 +6,8 @@ InModuleScope Arcus.Scripting.ARM { It "Replaces file path with inline file contents" { # Arrange $armTemplateFile = "$PSScriptRoot\Files\arm-template-inline.json" + $originalContents = Get-Content $armTemplateFile + try { # Act Inject-ArmContent -Path $armTemplateFile @@ -15,14 +17,14 @@ InModuleScope Arcus.Scripting.ARM { $actual = Get-Content $armTemplateFile $actual[7] | Should -Be ' "value": "this is a test value",' } finally { - $originalFile = "$PSScriptRoot\Files\arm-template-inline-org.json" - Get-Content $originalFile | Out-File -FilePath $armTemplateFile + $originalContents | Out-File -FilePath $armTemplateFile } } if ([Environment]::OSVersion.VersionString -like "*Windows*") { It "Replaces relative file path with file contents as JSON object (windows)" { # Arrange $armTemplateFile = "$PSScriptRoot\Files\arm-template-object (windows).json" + $originalContents = Get-Content $armTemplateFile try { # Act Inject-ArmContent -Path $armTemplateFile @@ -32,17 +34,16 @@ InModuleScope Arcus.Scripting.ARM { $actual = Get-Content $armTemplateFile $actual[7] | Should -Be ' "value": "{\r\n \"test\": \"this is a test value\"\r\n}",' } finally { - $originalFile = "$PSScriptRoot\Files\arm-template-object-org (windows).json" - Get-Content $originalFile | Out-File -FilePath $armTemplateFile + $originalContents | Out-File -FilePath $armTemplateFile } } It "Replaces absolute file path with file contents as JSON object (windows)" { # Arrange $armTemplateFile = "$PSScriptRoot\Files\arm-template-object-absolutepath (windows).json" $armTemplateDirectory = Split-Path $armTemplateFile -Parent - $armTemplate = Get-Content -path $armTemplateFile -Raw - $armTemplate = $armTemplate -replace '#{ArmTemplateDirectory}#', $armTemplateDirectory - $armTemplate | Set-Content -Path $armTemplateFile + $originalContents = Get-Content $armTemplateFile + $armTemplate = $originalContents -replace '#{ArmTemplateDirectory}#', $armTemplateDirectory + $armTemplate | Out-File -FilePath $armTemplateFile try { # Act @@ -53,14 +54,14 @@ InModuleScope Arcus.Scripting.ARM { $actual = Get-Content $armTemplateFile $actual[7] | Should -Be ' "value": "{\r\n \"test\": \"this is a test value\"\r\n}",' } finally { - $originalFile = "$PSScriptRoot\Files\arm-template-object-absolutepath-org (windows).json" - Get-Content $originalFile | Out-File -FilePath $armTemplateFile + $originalContents | Out-File -FilePath $armTemplateFile } } } else { It "Replaces relative file path with file contents as JSON object (linux)" { # Arrange $armTemplateFile = "$PSScriptRoot\Files\arm-template-object (linux).json" + $originalContents = Get-Content $armTemplateFile try { # Act Inject-ArmContent -Path $armTemplateFile @@ -70,17 +71,16 @@ InModuleScope Arcus.Scripting.ARM { $actual = Get-Content $armTemplateFile $actual[7] | Should -Be ' "value": "{\n \"test\": \"this is a test value\"\n}",' } finally { - $originalFile = "$PSScriptRoot\Files\arm-template-object-org (linux).json" - Get-Content $originalFile | Out-File -FilePath $armTemplateFile + $originalContents | Out-File -FilePath $armTemplateFile } } It "Replaces absolute file path with file contents as JSON object (linux)" { # Arrange $armTemplateFile = "$PSScriptRoot\Files\arm-template-object-absolutepath (linux).json" $armTemplateDirectory = Split-Path $armTemplateFile -Parent - $armTemplate = Get-Content -path $armTemplateFile -Raw - $armTemplate = $armTemplate -replace '#{ArmTemplateDirectory}#', $armTemplateDirectory - $armTemplate | Set-Content -Path $armTemplateFile + $originalContents = Get-Content -Path $armTemplateFile + $armTemplate = $originalContents -replace '#{ArmTemplateDirectory}#', $armTemplateDirectory + $armTemplate | Out-File -FilePath $armTemplateFile try { # Act @@ -91,14 +91,14 @@ InModuleScope Arcus.Scripting.ARM { $actual = Get-Content $armTemplateFile $actual[7] | Should -Be ' "value": "{\n \"test\": \"this is a test value\"\n}",' } finally { - $originalFile = "$PSScriptRoot\Files\arm-template-object-absolutepath-org (linux).json" - Get-Content $originalFile | Out-File -FilePath $armTemplateFile + $originalContents | Out-File -FilePath $armTemplateFile } } } It "Replaces file path with file contents as escaped JSON and replaced special characters" { # Arrange $armTemplateFile = "$PSScriptRoot\Files\arm-template-escape.json" + $originalContents = Get-Content $armTemplateFile try { # Act Inject-ArmContent -Path $armTemplateFile @@ -108,8 +108,7 @@ InModuleScope Arcus.Scripting.ARM { $actual = Get-Content $armTemplateFile $actual[7] | Should -Be ' "value": "",' } finally { - $originalFile = "$PSScriptRoot\Files\arm-template-escape-org.json" - Get-Content $originalFile | Out-File -FilePath $armTemplateFile + $originalContents | Out-File -FilePath $armTemplateFile } } } diff --git a/src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.Tests.Integration.pssproj b/src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.Tests.Integration.pssproj index a2706361..6398d166 100644 --- a/src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.Tests.Integration.pssproj +++ b/src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.Tests.Integration.pssproj @@ -70,17 +70,15 @@ - + + - - - diff --git a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-escape-org.json b/src/Arcus.Scripting.Tests.Integration/Files/arm-template-escape-org.json deleted file mode 100644 index d8e44f17..00000000 --- a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-escape-org.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "Microsoft.ApiManagement/service/apis", - "name": "[concat(parameters('ApiManagement.Name'),'/', parameters('ApiManagement.Api.Name'))]", - "apiVersion": "2019-01-01", - "properties": { - "subscriptionRequired": true, - "path": "demo", - "value": "${ ./../Files/arm-template-escape-value.xml, EscapeJson, ReplaceSpecialChars }$", - "format": "swagger-json" - }, - "tags": "[variables('Tags')]", - "dependsOn": [ - ] -} \ No newline at end of file diff --git a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-inline-org.json b/src/Arcus.Scripting.Tests.Integration/Files/arm-template-inline-org.json deleted file mode 100644 index b8de134c..00000000 --- a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-inline-org.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "Microsoft.ApiManagement/service/apis", - "name": "[concat(parameters('ApiManagement.Name'),'/', parameters('ApiManagement.Api.Name'))]", - "apiVersion": "2019-01-01", - "properties": { - "subscriptionRequired": true, - "path": "demo", - "value": "${ ./../Files/arm-template-inline-value.json }$", - "format": "swagger-json" - }, - "tags": "[variables('Tags')]", - "dependsOn": [ - ] -} \ No newline at end of file diff --git a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-absolutepath-org (linux).json b/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-absolutepath-org (linux).json deleted file mode 100644 index c2cac1c0..00000000 Binary files a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-absolutepath-org (linux).json and /dev/null differ diff --git a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-absolutepath-org (windows).json b/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-absolutepath-org (windows).json deleted file mode 100644 index a2c39bd4..00000000 Binary files a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-absolutepath-org (windows).json and /dev/null differ diff --git a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-org (linux).json b/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-org (linux).json deleted file mode 100644 index 0bc16d13..00000000 --- a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-org (linux).json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "Microsoft.ApiManagement/service/apis", - "name": "[concat(parameters('ApiManagement.Name'),'/', parameters('ApiManagement.Api.Name'))]", - "apiVersion": "2019-01-01", - "properties": { - "subscriptionRequired": true, - "path": "demo", - "value": "${ FileToInject='./../Files/arm-template-object-value (linux).json', InjectAsJsonObject }$", - "format": "swagger-json" - }, - "tags": "[variables('Tags')]", - "dependsOn": [ - ] -} \ No newline at end of file diff --git a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-org (windows).json b/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-org (windows).json deleted file mode 100644 index da0b91bb..00000000 --- a/src/Arcus.Scripting.Tests.Integration/Files/arm-template-object-org (windows).json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "Microsoft.ApiManagement/service/apis", - "name": "[concat(parameters('ApiManagement.Name'),'/', parameters('ApiManagement.Api.Name'))]", - "apiVersion": "2019-01-01", - "properties": { - "subscriptionRequired": true, - "path": "demo", - "value": "${ FileToInject='./../Files/arm-template-object-value (windows).json', ReplaceSpecialChars, InjectAsJsonObject }$", - "format": "swagger-json" - }, - "tags": "[variables('Tags')]", - "dependsOn": [ - ] -} \ No newline at end of file