Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

DscResource.Template: Update the integrate test template #15

Merged
merged 2 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Localized resources for helper module CommonResourceHelper.
# Localized resources for helper module DscResource.Common.

ConvertFrom-StringData @'
PropertyTypeInvalidForDesiredValues = Property 'DesiredValues' must be either a [System.Collections.Hashtable], [CimInstance] or [PSBoundParametersDictionary]. The type detected was {0}.
Expand Down
9 changes: 9 additions & 0 deletions TEMPLATE_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ for more information.
This is the change log for DscResource.Template. Any changes to the
DscResource.Template should be mentioned here for reference by the users.

### 2019-03-17

- Update the integrate test template to version 1.3.3 because the test
`'Should return $true when Test-DscConfiguration is run'` that did not
fail correctly if `Test-DscConfiguration` returned 'False'
([issue #14](https://github.com/PowerShell/DscResource.Template/issues/14)).
- Updated some comments in files that wrongly referenced a non-existent
module.

### 2019-02-03

- Initial commit to repository DscResource.Template.
Expand Down
28 changes: 16 additions & 12 deletions Tests/Integration/MSFT_Folder.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ if (Test-SkipContinuousIntegrationTask -Type 'Integration')

$script:dscModuleName = 'DscResource.Template'
$script:dscResourceFriendlyName = 'Folder'
$script:dcsResourceName = "MSFT_$($script:dscResourceFriendlyName)"
$script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)"

#region HEADER
# Integration Test Template Version: 1.3.1
region HEADER
# Integration Test Template Version: 1.3.3
[String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or `
(-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) )
Expand All @@ -25,17 +25,21 @@ if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCR
Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force
$TestEnvironment = Initialize-TestEnvironment `
-DSCModuleName $script:dscModuleName `
-DSCResourceName $script:dcsResourceName `
-DSCResourceName $script:dscResourceName `
-TestType Integration
#endregion

try
{
$configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1"
$configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1"
. $configFile

Describe "$($script:DSCResourceName)_Integration" {
$configurationName = "$($script:DSCResourceName)_Create_Config"
Describe "$($script:dscResourceName)_Integration" {
BeforeAll {
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test"
}

$configurationName = "$($script:dscResourceName)_Create_Config"

Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
Expand Down Expand Up @@ -70,7 +74,7 @@ try
It 'Should have set the resource and all the parameters should match' {
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript {
$_.ConfigurationName -eq $configurationName `
-and $_.ResourceId -eq "[$($script:dscResourceFriendlyName)]Integration_Test"
-and $_.ResourceId -eq $resourceId
}

$resourceCurrentState.Ensure | Should -Be 'Present'
Expand All @@ -82,11 +86,11 @@ try
}

It 'Should return $true when Test-DscConfiguration is run' {
Test-DscConfiguration -Verbose | Should -Be $true
Test-DscConfiguration -Verbose | Should -Be 'True'
}
}

$configurationName = "$($script:DSCResourceName)_Remove_Config"
$configurationName = "$($script:dscResourceName)_Remove_Config"

Context ('When using configuration {0}' -f $configurationName) {
It 'Should compile and apply the MOF without throwing' {
Expand Down Expand Up @@ -121,7 +125,7 @@ try
It 'Should have set the resource and all the parameters should match' {
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript {
$_.ConfigurationName -eq $configurationName `
-and $_.ResourceId -eq "[$($script:dscResourceFriendlyName)]Integration_Test"
-and $_.ResourceId -eq $resourceId
}

$resourceCurrentState.Ensure | Should -Be 'Absent'
Expand All @@ -133,7 +137,7 @@ try
}

It 'Should return $true when Test-DscConfiguration is run' {
Test-DscConfiguration -Verbose | Should -Be $true
Test-DscConfiguration -Verbose | Should -Be 'True'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Integration/integration_test_template.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#>

#region HEADER
# Integration Test Config Template Version: 1.2.1s
# Integration Test Config Template Version: 1.2.1
#endregion

$configFile = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path, 'json')
Expand Down
4 changes: 2 additions & 2 deletions Tests/Integration/integration_test_template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $script:dscResourceFriendlyName = '<ResourceFriendlyName>' # TODO: Example 'Fire
$script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" # TODO: Update prefix

#region HEADER
# Integration Test Template Version: 1.3.2
# Integration Test Template Version: 1.3.3
[String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or `
(-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) )
Expand Down Expand Up @@ -106,7 +106,7 @@ try
}

It 'Should return $true when Test-DscConfiguration is run' {
Test-DscConfiguration -Verbose | Should -Be $true
Test-DscConfiguration -Verbose | Should -Be 'True'
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/DscResource.LocalizationHelper.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Import the CommonResourceHelper module to test
# Import the DscResource.LocalizationHelper module to test
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules\DscResource.LocalizationHelper'

Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/DscResource.ResourceHelper.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Import the CommonResourceHelper module to test
# Import the DscResource.Common module to test
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules\DscResource.Common'

Expand Down