Skip to content

Commit

Permalink
test: simplify arm integration tests (#312)
Browse files Browse the repository at this point in the history
* test: simplify arm integration tests

* pr-fix: use correct set file command
  • Loading branch information
stijnmoreels authored Jun 21, 2022
1 parent 4cff971 commit 958b2dd
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 78 deletions.
35 changes: 17 additions & 18 deletions src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.ARM.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -108,8 +108,7 @@ InModuleScope Arcus.Scripting.ARM {
$actual = Get-Content $armTemplateFile
$actual[7] | Should -Be ' "value": "<Operation value=\"this is a test value\" />",'
} finally {
$originalFile = "$PSScriptRoot\Files\arm-template-escape-org.json"
Get-Content $originalFile | Out-File -FilePath $armTemplateFile
$originalContents | Out-File -FilePath $armTemplateFile
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,15 @@
<Content Include="appsettings.json" />
<Content Include="Blobs\arcus.png" />
<Content Include="Files\arm-template-object %28linux%29.json" />
<Content Include="Files\arm-template-object-org %28linux%29.json" />
<Content Include="Files\arm-template-object-absolutepath %28linux%29.json" />
<Content Include="Files\arm-template-object-absolutepath %28windows%29.json" />
<Content Include="Files\arm-template-object-value %28linux%29.json" />
<Content Include="Files\arm-template-escape-value.xml" />
<Content Include="Files\arm-template-escape.json" />
<Content Include="Files\arm-template-escape-org.json" />
<Content Include="Files\arm-template-object-value %28windows%29.json" />
<Content Include="Files\arm-template-object %28windows%29.json" />
<Content Include="Files\arm-template-object-org %28windows%29.json" />
<Content Include="Files\arm-template-inline.json" />
<Content Include="Files\arm-template-inline-value.json" />
<Content Include="Files\arm-template-inline-org.json" />
<Content Include="Files\IntegrationAccount\Agreements\agreement1.json" />
<Content Include="Files\IntegrationAccount\Agreements\agreement2.json" />
<Content Include="Files\IntegrationAccount\Assemblies\AssemblyThatDoesSomething.dll" />
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

0 comments on commit 958b2dd

Please sign in to comment.