|
1 | 1 | [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] |
2 | 2 | param () |
3 | 3 |
|
4 | | -$script:DSCModuleName = 'FileContentDsc' |
5 | | -$script:DSCResourceName = 'DSC_ReplaceText' |
| 4 | +$script:dscModuleName = 'FileContentDsc' |
| 5 | +$script:dscResourceName = 'DSC_ReplaceText' |
6 | 6 |
|
7 | | -#region HEADER |
8 | | -# Integration Test Template Version: 1.1.1 |
9 | | -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) |
10 | | - |
11 | | -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` |
12 | | - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) |
| 7 | +try |
| 8 | +{ |
| 9 | + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' |
| 10 | +} |
| 11 | +catch [System.IO.FileNotFoundException] |
13 | 12 | { |
14 | | - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) |
| 13 | + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' |
15 | 14 | } |
16 | 15 |
|
17 | | -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force |
18 | | -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force |
| 16 | +$script:testEnvironment = Initialize-TestEnvironment ` |
| 17 | + -DSCModuleName $script:dscModuleName ` |
| 18 | + -DSCResourceName $script:dscResourceName ` |
| 19 | + -ResourceType 'Mof' ` |
| 20 | + -TestType 'Integration' |
| 21 | + |
| 22 | +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') |
| 23 | + |
19 | 24 | # Helper module import required for the Get-FileEncoding function |
20 | | -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'Modules\FileContentDsc.Common') -Force |
21 | | -$TestEnvironment = Initialize-TestEnvironment ` |
22 | | - -DSCModuleName $script:DSCModuleName ` |
23 | | - -DSCResourceName $script:DSCResourceName ` |
24 | | - -TestType Integration |
25 | | -#endregion |
| 25 | +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\..\source\Modules\FileContentDsc.Common') -Force |
26 | 26 |
|
27 | 27 | try |
28 | 28 | { |
29 | | - Describe 'ReplaceText Integration Tests' { |
| 29 | + Describe "$($script:dscResourceName)_Integration" { |
30 | 30 | $script:confgurationFilePath = Join-Path -Path $PSScriptRoot -ChildPath 'DSC_ReplaceText.config.ps1' |
31 | 31 | $script:configurationName = 'ReplaceText' |
32 | 32 | $script:testTextFile = Join-Path -Path $TestDrive -ChildPath 'TestFile.txt' |
@@ -280,7 +280,5 @@ Setting3.Test=Value4 |
280 | 280 | } |
281 | 281 | finally |
282 | 282 | { |
283 | | - #region FOOTER |
284 | | - Restore-TestEnvironment -TestEnvironment $TestEnvironment |
285 | | - #endregion |
| 283 | + Restore-TestEnvironment -TestEnvironment $script:testEnvironment |
286 | 284 | } |
0 commit comments