From 1ac71d5506947a06a76f0a35571fa45fec0d13f6 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 28 Jan 2019 19:55:05 +0100 Subject: [PATCH 01/12] Changes to xPSDesiredStateConfiguration - In AppVeyor CI the tests are split into three separate jobs, and also running tests on two different build worker images (Windows Server 2012R2 and Windows Server 2016). The common tests are run on only one of the build worker images (Windows Server 2012R2). Helps with issue #477. --- README.md | 8 +- .../MSFT_xArchive.EndToEnd.Tests.ps1 | 6 + .../MSFT_xArchive.Integration.Tests.ps1 | 6 + Tests/Integration/MSFT_xDSCWebService.xxx.ps1 | 6 + ...FT_xEnvironmentResource.EndToEnd.Tests.ps1 | 6 + ...xEnvironmentResource.Integration.Tests.ps1 | 6 + .../MSFT_xGroupResource.Integration.Tests.ps1 | 6 + .../MSFT_xMsiPackage.EndToEnd.Tests.ps1 | 6 + .../MSFT_xMsiPackage.Integration.Tests.ps1 | 6 + ...SFT_xPackageResource.Integration.Tests.ps1 | 6 + .../MSFT_xRegistryResource.EndToEnd.Tests.ps1 | 6 + ...FT_xRegistryResource.Integration.Tests.ps1 | 6 + Tests/Integration/MSFT_xRemoteFile.Tests.ps1 | 8 +- ...MSFT_xScriptResource.Integration.Tests.ps1 | 6 + ...SFT_xServiceResource.Integration.Tests.ps1 | 18 +- .../MSFT_xUserResource.Integration.Tests.ps1 | 31 ++- ...MSFT_xWindowsFeature.Integration.Tests.ps1 | 7 +- ...ndowsOptionalFeature.Integration.Tests.ps1 | 7 + ...T_xWindowsPackageCab.Integration.Tests.ps1 | 6 + ...MSFT_xWindowsProcess.Integration.Tests.ps1 | 6 + .../xGroupSet.Integration.Tests.ps1 | 6 + .../xProcessSet.Integration.Tests.ps1 | 6 + .../xServiceSet.Integration.Tests.ps1 | 6 + .../xWindowsFeatureSet.Integration.Tests.ps1 | 6 + ...wsOptionalFeatureSet.Integration.Tests.ps1 | 6 + Tests/Unit/CommonResourceHelper.Tests.ps1 | 6 + Tests/Unit/MSFT_xArchive.Tests.ps1 | 6 + Tests/Unit/MSFT_xDSCWebService.Tests.ps1 | 6 + .../Unit/MSFT_xEnvironmentResource.Tests.ps1 | 6 + Tests/Unit/MSFT_xGroupResource.Tests.ps1 | 202 ++++++++------- Tests/Unit/MSFT_xMsiPackage.Tests.ps1 | 6 + Tests/Unit/MSFT_xPackageResource.Tests.ps1 | 7 + Tests/Unit/MSFT_xRegistryResource.Tests.ps1 | 56 ++-- Tests/Unit/MSFT_xRemoteFile.Tests.ps1 | 12 +- Tests/Unit/MSFT_xScriptResource.Tests.ps1 | 34 ++- Tests/Unit/MSFT_xServiceResource.Tests.ps1 | 6 + Tests/Unit/MSFT_xUserResource.Tests.ps1 | 124 ++++----- Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 | 78 +++--- .../MSFT_xWindowsOptionalFeature.Tests.ps1 | 20 +- Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 | 6 + Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 | 240 +++++++++--------- Tests/Unit/ResourceSetHelper.Tests.ps1 | 6 + appveyor.yml | 58 ++++- 43 files changed, 685 insertions(+), 387 deletions(-) diff --git a/README.md b/README.md index 83346c576..5847d4bb8 100644 --- a/README.md +++ b/README.md @@ -714,13 +714,19 @@ Publishes a 'FileInfo' object(s) to the pullserver configuration repository. It ### Unreleased +* Changes to xPSDesiredStateConfiguration + * In AppVeyor CI the tests are split into three separate jobs, and also + running tests on two different build worker images (Windows Server + 2012R2 and Windows Server 2016). The common tests are run on only + one of the build worker images (Windows Server 2012R2). Helps with + [issue #477](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/477). * xWindowsOptionalFeature * Suppress useless verbose output from `Import-Module` cmdlet. ([issue 453](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/453)) * Changes to xRemoteFile * Corrected a resource name in the example xRemoteFile_DownloadFileConfig.ps1 * Fix `MSFT_xDSCWebService` to find `Microsoft.Powershell.DesiredStateConfiguration.Service.Resources.dll` - when server is configured with pt-BR Locales ([issue #284](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/284)). + when server is configured with pt-BR Locales ([issue #284](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/284)). * Changes to xDSCWebService * Fixed an issue which prevented the removal of the IIS Application Pool created during deployment of an DSC Pull Server instance. ([issue #464](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/464)) * Fixed an issue where a Pull Server cannot be deployed on a machine when IIS Express is installed aside a full blown IIS ([issue #191](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/191)) diff --git a/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 index b47815e87..bb692e1b9 100644 --- a/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + Describe 'xArchive End to End Tests' { BeforeAll { # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment diff --git a/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 b/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 index 6006eaad8..12ca3ae83 100644 --- a/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + if ($PSVersionTable.PSVersion -lt [Version] '5.1') { Write-Warning -Message 'Cannot run PSDscResources integration tests on PowerShell versions lower than 5.1' diff --git a/Tests/Integration/MSFT_xDSCWebService.xxx.ps1 b/Tests/Integration/MSFT_xDSCWebService.xxx.ps1 index 64be95474..fa2baf9b0 100644 --- a/Tests/Integration/MSFT_xDSCWebService.xxx.ps1 +++ b/Tests/Integration/MSFT_xDSCWebService.xxx.ps1 @@ -6,6 +6,12 @@ # Run as an elevated administrator ###################################################################################### +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + # Create a unique name that we use for our temp files and folders [System.String] $tempFolderName = 'xDSCWebServiceTests_' + (Get-Date).ToString("yyyyMMdd_HHmmss") diff --git a/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 index 77f585c08..da536d074 100644 --- a/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 @@ -6,6 +6,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' diff --git a/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 index e3ec00477..af37a1bec 100644 --- a/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 @@ -3,6 +3,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' diff --git a/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 index 1f657e6e5..36a9d74e9 100644 --- a/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 @@ -1,6 +1,12 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] param () +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' diff --git a/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 index 09c870e34..699aa74f6 100644 --- a/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 @@ -4,6 +4,12 @@ also fail. #> +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' diff --git a/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 b/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 index 9b02c3c0b..9e3eb1ca3 100644 --- a/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $script:testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $script:commonTestHelperFilePath diff --git a/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 index 622062c57..df0384372 100644 --- a/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 @@ -1,3 +1,9 @@ +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + Import-Module "$PSScriptRoot\..\CommonTestHelper.psm1" $script:testEnvironment = Enter-DscResourceTestEnvironment ` diff --git a/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 index 3fc63dc70..28815380e 100644 --- a/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 @@ -5,6 +5,12 @@ If this happens to you, it is fixable, but the fix is difficult and time-consuming. #> +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' diff --git a/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 index 57b2eedb2..9e89e235b 100644 --- a/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 @@ -5,6 +5,12 @@ If this happens to you, it is fixable, but the fix is difficult and time-consuming. #> +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' diff --git a/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 b/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 index b111877d9..3652624f5 100644 --- a/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 +++ b/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 @@ -2,6 +2,12 @@ $Global:DSCModuleName = 'xPSDesiredStateConfiguration' # Example xNetworking $Global:DSCResourceName = 'MSFT_xRemoteFile' # Example MSFT_xFirewall +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + #region HEADER # Integration Test Template Version: 1.1.0 [String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) @@ -15,7 +21,7 @@ Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHel $TestEnvironment = Initialize-TestEnvironment ` -DSCModuleName $Global:DSCModuleName ` -DSCResourceName $Global:DSCResourceName ` - -TestType Integration + -TestType Integration #endregion # Using try/finally to always cleanup even if something awful happens. diff --git a/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 index a94199764..f2eb496ba 100644 --- a/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' diff --git a/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 index 8470e1d8e..14d02b249 100644 --- a/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 @@ -7,6 +7,12 @@ also fail. #> +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -116,7 +122,7 @@ try $resourceParameters = $script:existingServiceProperties It 'Should compile and apply the MOF without throwing' { - { + { . $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName & $configurationName -OutputPath $TestDrive @resourceParameters Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force @@ -179,7 +185,7 @@ try $resourceParameters = $script:newServiceProperties It 'Should compile and apply the MOF without throwing' { - { + { . $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName & $configurationName -OutputPath $TestDrive @resourceParameters Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force @@ -247,7 +253,7 @@ try } It 'Should compile and apply the MOF without throwing' { - { + { . $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName & $configurationName -OutputPath $TestDrive @resourceParameters Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force @@ -297,7 +303,7 @@ try } It 'Should compile and apply the MOF without throwing' { - { + { . $script:configurationCredentialOnlyFilePath -ConfigurationName $configurationName & $configurationName -OutputPath $TestDrive -ConfigurationData $configData @resourceParameters Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force @@ -342,7 +348,7 @@ try } It 'Should compile and apply the MOF without throwing' { - { + { . $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName & $configurationName -OutputPath $TestDrive @resourceParameters Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force @@ -380,7 +386,7 @@ try } It 'Should compile and apply the MOF without throwing' { - { + { . $script:configurationAllExceptCredentialFilePath -ConfigurationName $configurationName & $configurationName -OutputPath $TestDrive @resourceParameters Start-DscConfiguration -Path $TestDrive -ErrorAction 'Stop' -Wait -Force diff --git a/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 index 5058e063d..8b8408d59 100644 --- a/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 @@ -1,13 +1,18 @@ <# To run these tests, the currently logged on user must have rights to create a user. - These integration tests cover creating a brand new user, updating values + These integration tests cover creating a brand new user, updating values of a user that already exists, and deleting a user that exists. -#> - +#> # Suppressing this rule since we need to create a plaintext password to test this resource [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force @@ -34,13 +39,13 @@ try { } ) } - + Context 'Should create a new user' { $configurationName = 'MSFT_xUser_NewUser' $configurationPath = Join-Path -Path $TestDrive -ChildPath $configurationName $logPath = Join-Path -Path $TestDrive -ChildPath 'NewUser.log' - + $testUserName = 'TestUserName12345' $testUserPassword = 'StrongOne7.' $testDescription = 'Test Description' @@ -65,7 +70,7 @@ try { It 'Should be able to call Get-DscConfiguration without throwing' { { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not Throw } - + It 'Should return the correct configuration' { $currentConfig = Get-DscConfiguration -Verbose -ErrorAction Stop $currentConfig.UserName | Should Be $testUserName @@ -87,13 +92,13 @@ try { } } } - + Context 'Should update an existing user' { $configurationName = 'MSFT_xUser_UpdateUser' $configurationPath = Join-Path -Path $TestDrive -ChildPath $configurationName $logPath = Join-Path -Path $TestDrive -ChildPath 'UpdateUser.log' - + $testUserName = 'TestUserName12345' $testUserPassword = 'StrongOne7.' $testDescription = 'New Test Description' @@ -118,7 +123,7 @@ try { It 'Should be able to call Get-DscConfiguration without throwing' { { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not Throw } - + It 'Should return the correct configuration' { $currentConfig = Get-DscConfiguration -Verbose -ErrorAction Stop $currentConfig.UserName | Should Be $testUserName @@ -140,13 +145,13 @@ try { } } } - + Context 'Should delete an existing user' { $configurationName = 'MSFT_xUser_DeleteUser' $configurationPath = Join-Path -Path $TestDrive -ChildPath $configurationName $logPath = Join-Path -Path $TestDrive -ChildPath 'DeleteUser.log' - + $testUserName = 'TestUserName12345' $testUserPassword = 'StrongOne7.' $secureTestPassword = ConvertTo-SecureString $testUserPassword -AsPlainText -Force @@ -170,7 +175,7 @@ try { It 'Should be able to call Get-DscConfiguration without throwing' { { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should Not Throw } - + It 'Should return the correct configuration' { $currentConfig = Get-DscConfiguration -Verbose -ErrorAction Stop $currentConfig.UserName | Should Be $testUserName @@ -189,7 +194,7 @@ try { } } } - + } } finally diff --git a/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 index d0a2635e1..0c1c9a25b 100644 --- a/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 @@ -4,11 +4,16 @@ RSAT-File-Services is set as the feature to test installing/uninstalling a feature with subfeatures. #> - # Suppressing this rule since we need to create a plaintext password to test this resource [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force diff --git a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 index c908d2fe2..6166c14d2 100644 --- a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 @@ -1,3 +1,10 @@ +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + + Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') $script:testEnvironment = Enter-DscResourceTestEnvironment ` diff --git a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 index cad1fa06d..941438cff 100644 --- a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 @@ -1,3 +1,9 @@ +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') $script:testEnvironment = Enter-DscResourceTestEnvironment ` diff --git a/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 index 12d14614c..c84dab40f 100644 --- a/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 @@ -9,6 +9,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force diff --git a/Tests/Integration/xGroupSet.Integration.Tests.ps1 b/Tests/Integration/xGroupSet.Integration.Tests.ps1 index 5577c34ae..f960aa9d5 100644 --- a/Tests/Integration/xGroupSet.Integration.Tests.ps1 +++ b/Tests/Integration/xGroupSet.Integration.Tests.ps1 @@ -4,6 +4,12 @@ param () $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' diff --git a/Tests/Integration/xProcessSet.Integration.Tests.ps1 b/Tests/Integration/xProcessSet.Integration.Tests.ps1 index 310fa145e..c455cb61d 100644 --- a/Tests/Integration/xProcessSet.Integration.Tests.ps1 +++ b/Tests/Integration/xProcessSet.Integration.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' diff --git a/Tests/Integration/xServiceSet.Integration.Tests.ps1 b/Tests/Integration/xServiceSet.Integration.Tests.ps1 index 2fe6e0c2c..654fa1484 100644 --- a/Tests/Integration/xServiceSet.Integration.Tests.ps1 +++ b/Tests/Integration/xServiceSet.Integration.Tests.ps1 @@ -7,6 +7,12 @@ also fail. #> +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' diff --git a/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 b/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 index d4c94f77d..db5a59031 100644 --- a/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 +++ b/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' diff --git a/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 b/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 index 46899f142..3a02d84d5 100644 --- a/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 +++ b/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +{ + Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' diff --git a/Tests/Unit/CommonResourceHelper.Tests.ps1 b/Tests/Unit/CommonResourceHelper.Tests.ps1 index d04c594ed..449b208bf 100644 --- a/Tests/Unit/CommonResourceHelper.Tests.ps1 +++ b/Tests/Unit/CommonResourceHelper.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + Describe 'CommonResourceHelper Unit Tests' { BeforeAll { # Import the CommonResourceHelper module to test diff --git a/Tests/Unit/MSFT_xArchive.Tests.ps1 b/Tests/Unit/MSFT_xArchive.Tests.ps1 index f81acbbfb..9b96aaddc 100644 --- a/Tests/Unit/MSFT_xArchive.Tests.ps1 +++ b/Tests/Unit/MSFT_xArchive.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + Describe 'xArchive Unit Tests' { BeforeAll { # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment diff --git a/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 b/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 index b19c0fc88..48812c0ee 100644 --- a/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 +++ b/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 @@ -1,6 +1,12 @@ $script:dscModuleName = 'xPSDesiredStateConfiguration' $script:dscResourceName = 'MSFT_xDSCWebService' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + #region HEADER # Integration Test Template Version: 1.1.0 [String] $script:moduleRoot = Split-Path -Parent -Path (Split-Path -Parent -Path $PSScriptRoot) diff --git a/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 b/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 index c605e463a..638c66008 100644 --- a/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' diff --git a/Tests/Unit/MSFT_xGroupResource.Tests.ps1 b/Tests/Unit/MSFT_xGroupResource.Tests.ps1 index ddb20e07b..89cc29357 100644 --- a/Tests/Unit/MSFT_xGroupResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xGroupResource.Tests.ps1 @@ -1,6 +1,12 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -114,7 +120,7 @@ try It 'Should return output Get-TargetResourceOnFullSKU with all parameters when not on Nano Server' { $getTargetResourceResult = Get-TargetResource -GroupName $script:testGroupName -Credential $script:testCredential - + Assert-MockCalled -CommandName 'Test-IsNanoServer' Assert-MockCalled -CommandName 'Get-TargetResourceOnFullSKU' -ParameterFilter { $GroupName -eq $script:testGroupName -and $Credential -eq $script:testCredential } $getTargetResourceResult.TestResult | Should Be 'OnFullSKU' @@ -122,9 +128,9 @@ try It 'Should call Get-TargetResourceOnNanoServer with all parameters when on Nano Server' { Mock -CommandName 'Test-IsNanoServer' -MockWith { return $true } - + $getTargetResourceResult = Get-TargetResource -GroupName $script:testGroupName -Credential $script:testCredential - + Assert-MockCalled -CommandName 'Test-IsNanoServer' Assert-MockCalled -CommandName 'Get-TargetResourceOnNanoServer' -ParameterFilter { $GroupName -eq $script:testGroupName -and $Credential -eq $script:testCredential } $getTargetResourceResult.TestResult | Should Be 'OnNanoServer' @@ -144,16 +150,16 @@ try It 'Should call Set-TargetResourceOnFullSKU with all parameters when not on Nano Server' { Set-TargetResource -GroupName $script:testGroupName -Credential $script:testCredential - + Assert-MockCalled -CommandName 'Test-IsNanoServer' Assert-MockCalled -CommandName 'Set-TargetResourceOnFullSKU' -ParameterFilter { $GroupName -eq $script:testGroupName -and $Credential -eq $script:testCredential } } It 'Should call Set-TargetResourceOnNanoServer with all parameters when on Nano Server' { Mock -CommandName 'Test-IsNanoServer' -MockWith { return $true } - + Set-TargetResource -GroupName $script:testGroupName -Credential $script:testCredential - + Assert-MockCalled -CommandName 'Test-IsNanoServer' Assert-MockCalled -CommandName 'Set-TargetResourceOnNanoServer' -ParameterFilter { $GroupName -eq $script:testGroupName -and $Credential -eq $script:testCredential } } @@ -172,16 +178,16 @@ try It 'Should call Test-TargetResourceOnFullSKU with all parameters when not on Nano Server' { $testTargetResourceResult = Test-TargetResource -GroupName $script:testGroupName -Credential $script:testCredential - + Assert-MockCalled -CommandName 'Test-IsNanoServer' Assert-MockCalled -CommandName 'Test-TargetResourceOnFullSKU' -ParameterFilter { $GroupName -eq $script:testGroupName -and $Credential -eq $script:testCredential } } It 'Should call Test-TargetResourceOnNanoServer with all parameters when on Nano Server' { Mock -CommandName 'Test-IsNanoServer' -MockWith { return $true } - + $testTargetResourceResult = Test-TargetResource -GroupName $script:testGroupName -Credential $script:testCredential - + Assert-MockCalled -CommandName 'Test-IsNanoServer' Assert-MockCalled -CommandName 'Test-TargetResourceOnNanoServer' -ParameterFilter { $GroupName -eq $script:testGroupName -and $Credential -eq $script:testCredential } } @@ -189,7 +195,7 @@ try Context 'Assert-GroupNameValid' { $invalidCharacters = @( '\', '/', '"', '[', ']', ':', '|', '<', '>', '+', '=', ';', ',', '?', '*', '@' ) - + foreach ($invalidCharacter in $invalidCharacters) { It "Should throw error if name contains invalid character '$invalidCharacter'" { @@ -221,7 +227,7 @@ try Context 'Test-IsLocalMachine' { Mock -CommandName 'Get-CimInstance' -MockWith { } - + $localMachineScopes = @( '.', $env:computerName, 'localhost', '127.0.0.1' ) foreach ($localMachineScope in $localMachineScopes) @@ -239,7 +245,7 @@ try It 'Should return true if custom local IP address provided and Get-CimInstance contains matching IP address' { Mock -CommandName 'Get-CimInstance' -MockWith { return @{ IPAddress = @($customLocalIPAddress, '789.1.2.3')} } - + Test-IsLocalMachine -Scope $customLocalIPAddress | Should Be $true } @@ -308,12 +314,12 @@ try $testMembers = @('User1', 'User2') Mock -CommandName 'Get-MembersOnNanoServer' -MockWith { return @() } - + It 'Should return Ensure as Absent when Get-LocalGroup throws a GroupNotFound exception' { Mock -CommandName 'Get-LocalGroup' -MockWith { Write-Error -Message 'Test error message' -CategoryReason 'GroupNotFoundException' } - + $getTargetResourceResult = Get-TargetResourceOnNanoServer -GroupName $script:testGroupName - + Assert-MockCalled -CommandName 'Get-LocalGroup' -ParameterFilter { $Name -eq $script:testGroupName } $getTargetResourceResult -is [Hashtable] | Should Be $true @@ -324,17 +330,17 @@ try It 'Should throw an error when Get-LocalGroup throws an exception other than GroupNotFound' { Mock -CommandName 'Get-LocalGroup' -MockWith { Write-Error -Message $script:testErrorMessage -CategoryReason 'OtherException' } - + { $getTargetResourceResult = Get-TargetResourceOnNanoServer -GroupName $script:testGroupName } | Should Throw $script:testErrorMessage - + Assert-MockCalled -CommandName 'Get-LocalGroup' -ParameterFilter { $Name -eq $script:testGroupName } } It 'Should return correct hashtable values when Get-LocalGroup returns a valid, existing group without members' { $script:testLocalGroup.Description = $script:testGroupDescription - + Mock -CommandName 'Get-LocalGroup' -MockWith { return $script:testLocalGroup } - + $getTargetResourceResult = Get-TargetResourceOnNanoServer -GroupName $script:testGroupName Assert-MockCalled -CommandName 'Get-LocalGroup' -ParameterFilter { $Name -eq $script:testGroupName } @@ -350,12 +356,12 @@ try It 'Should return correct hashtable values when Get-LocalGroup returns a valid, existing group with members' { $script:testLocalGroup.Description = $script:testGroupDescription - + Mock -CommandName 'Get-LocalGroup' -MockWith { return $script:testLocalGroup } Mock -CommandName 'Get-MembersOnNanoServer' -MockWith { return $testMembers } - + $getTargetResourceResult = Get-TargetResourceOnNanoServer -GroupName $script:testGroupName - + Assert-MockCalled -CommandName 'Get-LocalGroup' -ParameterFilter { $Name -eq $script:testGroupName } Assert-MockCalled -CommandName 'Get-MembersOnNanoServer' -ParameterFilter { $Group -eq $script:testLocalGroup } @@ -376,7 +382,7 @@ try Mock -CommandName 'Get-MembersOnNanoServer' -MockWith { } Mock -CommandName 'Add-LocalGroupMember' -MockWith { } Mock -CommandName 'Remove-LocalGroupMember' -MockWith { } - + It 'Should not attempt to remove an absent group when Ensure is Absent' { Set-TargetResourceOnNanoServer -GroupName $script:testGroupName -Ensure 'Absent' @@ -529,7 +535,7 @@ try It 'Should remove a member from an existing group using MembersToExclude' { $testMembers = @( $script:testMemberName2 ) - + Set-TargetResourceOnNanoServer -GroupName $script:testGroupName -MembersToExclude $testMembers -Ensure 'Present' Assert-MockCalled -CommandName 'Get-LocalGroup' -ParameterFilter { $Name -eq $script:testGroupName } @@ -660,13 +666,13 @@ try Context 'Test-TargetResourceOnNanoServer' { Mock -CommandName 'Get-LocalGroup' -MockWith { Write-Error -Message 'Test error message' -CategoryReason 'GroupNotFoundException' } Mock -CommandName 'Get-MembersOnNanoServer' -MockWith { } - + It 'Should return true for an absent group when Ensure is Absent' { Test-TargetResourceOnNanoServer -GroupName $script:testGroupName -Ensure 'Absent' | Should Be $true Assert-MockCalled -CommandName 'Get-LocalGroup' -ParameterFilter { $Name -eq $script:testGroupName } } - + It 'Should return false for an absent group when Ensure is Present' { Test-TargetResourceOnNanoServer -GroupName $script:testGroupName -Ensure 'Present' | Should Be $false @@ -695,7 +701,7 @@ try It 'Should return true for an existing group with a matching description' { $script:testLocalGroup.Description = $script:testGroupDescription - + Test-TargetResourceOnNanoServer -GroupName $script:testGroupName -Description $script:testGroupDescription -Ensure 'Present' | Should Be $true Assert-MockCalled -CommandName 'Get-LocalGroup' -ParameterFilter { $Name -eq $script:testGroupName } @@ -703,7 +709,7 @@ try It 'Should return false for an existing group with a mismatching description' { $script:testLocalGroup.Description = $script:testGroupDescription - + Test-TargetResourceOnNanoServer -GroupName $script:testGroupName -Description 'Wrong description' -Ensure 'Present' | Should Be $false Assert-MockCalled -CommandName 'Get-LocalGroup' -ParameterFilter { $Name -eq $script:testGroupName } @@ -847,10 +853,10 @@ try Mock -CommandName 'Get-Group' -MockWith { } Mock -CommandName 'Get-MembersOnFullSKU' -MockWith { return @() } Mock -CommandName 'Remove-DisposableObject' -MockWith { } - + It 'Should return Ensure as Absent when Get-Group returns null' { $getTargetResourceResult = Get-TargetResourceOnFullSKU -GroupName $script:testGroupName - + Assert-MockCalled -CommandName 'Get-Group' -ParameterFilter { $GroupName -eq $script:testGroupName } Assert-MockCalled -CommandName 'Remove-DisposableObject' @@ -862,9 +868,9 @@ try It 'Should return correct hashtable values when Get-Group returns a valid, existing group without members' { $script:testGroup.Description = $script:testGroupDescription - + Mock -CommandName 'Get-Group' -MockWith { return $script:testGroup } - + $getTargetResourceResult = Get-TargetResourceOnFullSKU -GroupName $script:testGroupName Assert-MockCalled -CommandName 'Get-Group' -ParameterFilter { $GroupName -eq $script:testGroupName } @@ -881,12 +887,12 @@ try It 'Should return correct hashtable values when Get-Group returns a valid, existing group with members' { $testGroup.Description = $script:testGroupDescription - + Mock -CommandName 'Get-Group' -MockWith { return $script:testGroup } Mock -CommandName 'Get-MembersOnFullSKU' -MockWith { return $testMembers } - + $getTargetResourceResult = Get-TargetResourceOnFullSKU -GroupName $script:testGroupName - + Assert-MockCalled -CommandName 'Get-Group' -ParameterFilter { $GroupName -eq $script:testGroupName } Assert-MockCalled -CommandName 'Get-MembersOnFullSKU' -ParameterFilter { $Group -eq $script:testGroup } Assert-MockCalled -CommandName 'Remove-DisposableObject' @@ -903,36 +909,36 @@ try Context 'Set-TargetResourceOnFullSKU' { Mock -CommandName 'Get-Group' -MockWith { } Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { } - Mock -CommandName 'ConvertTo-UniquePrincipalsList' -MockWith { + Mock -CommandName 'ConvertTo-UniquePrincipalsList' -MockWith { $memberPrincipals = @() if ($MemberNames -contains $script:testUserPrincipal1.Name) { $memberPrincipals += @( $script:testUserPrincipal1` ) } - + if ($MemberNames -contains $script:testUserPrincipal2.Name) { $memberPrincipals += @( $script:testUserPrincipal2 ) } - + if ($MemberNames -contains $script:testUserPrincipal3.Name) { $memberPrincipals += @( $script:testUserPrincipal3 ) } return $memberPrincipals - } - + } + Mock -CommandName 'Clear-GroupMembers' -MockWith { } Mock -CommandName 'Add-GroupMember' -MockWith { } Mock -CommandName 'Remove-GroupMember' -MockWith { } Mock -CommandName 'Remove-Group' -MockWith { } Mock -CommandName 'Save-Group' -MockWith { } - + Mock -CommandName 'Remove-DisposableObject' -MockWith { } Mock -CommandName 'Get-PrincipalContext' -MockWith { return $script:testPrincipalContext } - + It 'Should not attempt to remove an absent group when Ensure is Absent' { Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Ensure 'Absent' @@ -941,7 +947,7 @@ try Assert-MockCalled -CommandName 'Remove-Group' -ParameterFilter { $Group.Name -eq $script:testGroupName } -Times 0 -Scope 'It' Assert-MockCalled -CommandName 'Remove-DisposableObject' -Scope 'It' } - + It 'Should create an empty group' { Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Ensure 'Present' @@ -962,7 +968,7 @@ try It 'Should create a group with one local member using Members' { $testMembers = @( $script:testUserPrincipal1.Name ) - + Mock -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.DirectoryServices.AccountManagement.GroupPrincipal' } -MockWith { return $testGroup } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Ensure 'Present' @@ -978,8 +984,8 @@ try It 'Should create a group with two local members using Members' { $testMembers = @( $script:testUserPrincipal1.Name, $script:testUserPrincipal2.Name ) - - Mock -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.DirectoryServices.AccountManagement.GroupPrincipal' } -MockWith { return $testGroup } + + Mock -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.DirectoryServices.AccountManagement.GroupPrincipal' } -MockWith { return $testGroup } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Ensure 'Present' @@ -995,7 +1001,7 @@ try It 'Should create a group with one local member using MembersToInclude' { $testMembers = @( $script:testUserPrincipal1.Name ) - + Mock -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.DirectoryServices.AccountManagement.GroupPrincipal' } -MockWith { return $testGroup } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToInclude $testMembers -Ensure 'Present' @@ -1011,7 +1017,7 @@ try It 'Should create a group with two local members using MembersToInclude' { $testMembers = @( $script:testUserPrincipal1.Name, $script:testUserPrincipal2.Name ) - + Mock -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.DirectoryServices.AccountManagement.GroupPrincipal' } -MockWith { return $testGroup } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToInclude $testMembers -Ensure 'Present' @@ -1030,7 +1036,7 @@ try It 'Should add a member to an existing group with no members using Members' { $testMembers = @( $script:testUserPrincipal1.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @() } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Ensure 'Present' @@ -1046,7 +1052,7 @@ try It 'Should add two members to an existing group with one of the members using Members' { $testMembers = @( $script:testUserPrincipal1.Name, $script:testUserPrincipal2.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1 ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Ensure 'Present' @@ -1063,7 +1069,7 @@ try It 'Should add a member to an existing group with no members using MembersToInclude' { $testMembers = @( $script:testUserPrincipal1.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @() } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToInclude $testMembers -Ensure 'Present' @@ -1079,7 +1085,7 @@ try It 'Should add two members to an existing group with one of the members using MembersToInclude' { $testMembers = @( $script:testUserPrincipal1.Name, $script:testUserPrincipal2.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1 ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToInclude $testMembers -Ensure 'Present' @@ -1096,7 +1102,7 @@ try It 'Should remove a member from an existing group using Members' { $testMembers = @( $script:testUserPrincipal1.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Ensure 'Present' @@ -1112,7 +1118,7 @@ try It 'Should clear group members from an existing group using Members' { $testMembers = @( ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Ensure 'Present' @@ -1127,7 +1133,7 @@ try It 'Should remove a member from an existing group using MembersToExclude' { $testMembers = @( $script:testUserPrincipal2.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToExclude $testMembers -Ensure 'Present' @@ -1143,7 +1149,7 @@ try It 'Should add a user and remove a user using Members' { $testMembers = @( $script:testUserPrincipal1.Name, $script:testUserPrincipal3.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Ensure 'Present' @@ -1161,9 +1167,9 @@ try It 'Should add a user and remove a user using MembersToInclude and MembersToExclude at the same time' { $testMembersToInclude = @( $script:testUserPrincipal3.Name ) $testMembersToExclude = @( $script:testUserPrincipal2.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) } - + Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToInclude $testMembersToInclude -MembersToExclude $testMembersToExclude -Ensure 'Present' Assert-MockCalled -CommandName 'Get-PrincipalContext' @@ -1206,8 +1212,8 @@ try It 'Should not modify group if member specified by MembersToInclude is already in group' { $testMembers = @( $script:testUserPrincipal1.Name, $script:testUserPrincipal2.Name ) - - Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) } + + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToInclude $testMembers -Ensure 'Present' @@ -1220,7 +1226,7 @@ try It 'Should not modify group if member specified by MembersToExclude is not in group' { $testMembers = @( $script:testUserPrincipal3.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToExclude $testMembers -Ensure 'Present' @@ -1234,7 +1240,7 @@ try It 'Should not modify group if members specified by Members match group members' { $testMembers = @( $script:testUserPrincipal1.Name, $script:testUserPrincipal2.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Ensure 'Present' @@ -1248,7 +1254,7 @@ try It 'Should not modify group if MembersToInclude is empty' { $testMembers = @( ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToInclude $testMembers -Ensure 'Present' @@ -1276,7 +1282,7 @@ try It 'Should not modify group if both MembersToInclude and MembersToExclude are empty' { $testMembers = @( ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @( ) } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToInclude $testMembers -MembersToExclude $testMembers -Ensure 'Present' @@ -1290,7 +1296,7 @@ try It 'Should not modify group with no members if Members is empty' { $testMembers = @( ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Ensure 'Present' @@ -1322,7 +1328,7 @@ try It 'Should pass Credential to all appropriate functions when using Members' { $testMembers = @( $script:testUserPrincipal1.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @() } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Credential $script:testCredential -Ensure 'Present' @@ -1333,7 +1339,7 @@ try It 'Should pass Credential to all appropriate functions when using MembersToInclude and MembersToExclude' { $testMembers = @( $script:testUserPrincipal1.Name ) - + Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { return @() } Set-TargetResourceOnFullSKU -GroupName $script:testGroupName -Members $testMembers -Credential $script:testCredential -Ensure 'Present' @@ -1348,19 +1354,19 @@ try Context 'Test-TargetResourceOnFullSKU' { Mock -CommandName 'Get-Group' -MockWith { } Mock -CommandName 'Get-MembersAsPrincipalsList' -MockWith { } - Mock -CommandName 'ConvertTo-UniquePrincipalsList' -MockWith { + Mock -CommandName 'ConvertTo-UniquePrincipalsList' -MockWith { $memberPrincipals = @() if ($MemberNames -contains $script:testUserPrincipal1.Name) { $memberPrincipals += @( $script:testUserPrincipal1` ) } - + if ($MemberNames -contains $script:testUserPrincipal2.Name) { $memberPrincipals += @( $script:testUserPrincipal2 ) } - + if ($MemberNames -contains $script:testUserPrincipal3.Name) { $memberPrincipals += @( $script:testUserPrincipal3 ) @@ -1368,10 +1374,10 @@ try return $memberPrincipals } - + Mock -CommandName 'Remove-DisposableObject' -MockWith { } Mock -CommandName 'Get-PrincipalContext' -MockWith { return $script:testPrincipalContext } - + It 'Should return true for an absent group when Ensure is Absent' { Test-TargetResourceOnFullSKU -GroupName $script:testGroupName -Ensure 'Absent' | Should Be $true @@ -1379,7 +1385,7 @@ try Assert-MockCalled -CommandName 'Get-Group' -ParameterFilter { $GroupName -eq $script:testGroupName } -Scope 'It' Assert-MockCalled -CommandName 'Remove-DisposableObject' } - + It 'Should return false for an absent group when Ensure is Present' { Test-TargetResourceOnFullSKU -GroupName $script:testGroupName -Ensure 'Present' | Should Be $false @@ -1408,7 +1414,7 @@ try It 'Should return true for an existing group with a matching description' { $script:testGroup.Description = $script:testGroupDescription - + Test-TargetResourceOnFullSKU -GroupName $script:testGroupName -Description $script:testGroupDescription -Ensure 'Present' | Should Be $true Assert-MockCalled -CommandName 'Get-PrincipalContext' @@ -1418,7 +1424,7 @@ try It 'Should return false for an existing group with a mismatching description' { $script:testGroup.Description = $script:testGroupDescription - + Test-TargetResourceOnFullSKU -GroupName $script:testGroupName -Description 'Wrong description' -Ensure 'Present' | Should Be $false Assert-MockCalled -CommandName 'Get-PrincipalContext' @@ -1561,7 +1567,7 @@ try { Test-TargetResourceOnFullSKU -GroupName $script:testGroupName -MembersToInclude $testMembersToInclude -MembersToExclude $testMembersToExclude -Ensure 'Present' } | Should Throw $errorMessage } } - + Context 'Get-MembersOnFullSKU' { $principalContextCache = @{} $disposables = New-Object -TypeName 'System.Collections.ArrayList' @@ -1613,7 +1619,7 @@ try $expectedGetMembersResult = @( $expectedName1, $expectedName2 ) $getMembersResult = Get-MembersOnFullSKU -Group $script:testGroup -PrincipalContextCache $principalContextCache -Disposables $disposables - + (Compare-Object -ReferenceObject $expectedGetMembersResult -DifferenceObject $getMembersResult) | Should Be $null Assert-MockCalled -CommandName 'Get-MembersAsPrincipalsList' -ParameterFilter { $Group.Name -eq $script:testGroupName } @@ -1623,16 +1629,16 @@ try Context 'Get-MembersAsPrincipalsList' { $principalContextCache = @{} $disposables = New-Object -TypeName 'System.Collections.ArrayList' - + Mock -CommandName 'Get-GroupMembersFromDirectoryEntry' -MockWith { } - + Mock -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.DirectoryServices.DirectoryEntry' } -MockWith { return $ArgumentList[0] } - + Mock -CommandName 'Get-PrincipalContext' -MockWith { return $script:testPrincipalContext } Mock -CommandName 'Test-IsLocalMachine' -MockWith { return $true } - + Mock -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.Security.Principal.SecurityIdentifier' } -MockWith { return 'S-1-0-0' } @@ -1714,7 +1720,7 @@ try It 'Should pass Credential to appropriate functions' { $getMembersResult = Get-MembersAsPrincipalsList -Group $script:testGroup -Credential $script:testCredential -PrincipalContextCache $principalContextCache -Disposables $disposables - + Assert-MockCalled -CommandName 'Get-PrincipalContext' -ParameterFilter { $Credential -eq $script:testCredential } Assert-MockCalled -CommandName 'Get-PrincipalContext' -ParameterFilter { $Credential -eq $script:testCredential} } @@ -1731,7 +1737,7 @@ try Context 'ConvertTo-UniquePrincipalsList' { $principalContextCache = @{} $disposables = New-Object -TypeName 'System.Collections.ArrayList' - + $testDomainUser1 = @{ Name = 'TestDomainUser1' SamAccountName = 'TestSamAccountName1' @@ -1751,11 +1757,11 @@ try $script:testUserPrincipal3.Name { return $script:testUserPrincipal3 } $testDomainUser1.Name { return $testDomainUser1 } } - } - + } + It 'Should not return duplicate local prinicpals' { $memberNames = @( $script:testUserPrincipal1.Name, $script:testUserPrincipal1.Name, $script:testUserPrincipal2.Name ) - + $uniquePrincipalsList = ConvertTo-UniquePrincipalsList -MemberNames $memberNames -PrincipalContextCache $principalContextCache -Disposables $disposables $uniquePrincipalsList | Should Be @( $script:testUserPrincipal1, $script:testUserPrincipal2 ) @@ -1787,7 +1793,7 @@ try Context 'ConvertTo-Principal' { $principalContextCache = @{} $disposables = New-Object -TypeName 'System.Collections.ArrayList' - + Mock -CommandName 'Split-MemberName' -MockWith { return $script:localDomain, $MemberName } Mock -CommandName 'Test-IsLocalMachine' -MockWith { return $true } Mock -CommandName 'Get-PrincipalContext' -MockWith { return $script:testPrincipalContext } @@ -1840,7 +1846,7 @@ try It 'Should throw if principal cannot be found' { $errorMessage = ($script:localizedData.CouldNotFindPrincipal -f $script:testUserPrincipal1.Name) - + { $convertToPrincipalResult = ConvertTo-Principal ` -MemberName $script:testUserPrincipal1.Name ` -PrincipalContextCache $principalContextCache ` @@ -1886,7 +1892,7 @@ try Context 'Get-PrincipalContext' { $fakePrincipalContext = 'FakePrincipalContext' - + Mock -CommandName 'Test-IsLocalMachine' -MockWith { return $true } Mock -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.DirectoryServices.AccountManagement.PrincipalContext' } -MockWith { $fakePrincipalContext } @@ -1912,12 +1918,12 @@ try It 'Should return the local principal context from the cache' { $principalContextCache = @{ $script:localDomain = $script:testPrincipalContext } $disposables = New-Object -TypeName 'System.Collections.ArrayList' - + Get-PrincipalContext -Scope $script:localDomain -PrincipalContextCache $principalContextCache -Disposables $disposables Assert-MockCalled -CommandName 'Test-IsLocalMachine' -ParameterFilter { $Scope -eq $script:localDomain } Assert-MockCalled -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.DirectoryServices.AccountManagement.PrincipalContext' } -Times 0 -Scope 'It' - + $principalContextCache.$script:localDomain | Should Not Be $fakePrincipalContext $disposables.Contains($fakePrincipalContext) | Should Be $false } @@ -1929,7 +1935,7 @@ try $disposables = New-Object -TypeName 'System.Collections.ArrayList' $customDomain = 'CustomDomain' - + Get-PrincipalContext -Scope $customDomain -PrincipalContextCache $principalContextCache -Disposables $disposables Assert-MockCalled -CommandName 'Test-IsLocalMachine' -ParameterFilter { $Scope -eq $customDomain } @@ -1948,7 +1954,7 @@ try $disposables = New-Object -TypeName 'System.Collections.ArrayList' $customDomain = 'CustomDomain' - + Get-PrincipalContext -Scope $customDomain -Credential $script:testCredential -PrincipalContextCache $principalContextCache -Disposables $disposables Assert-MockCalled -CommandName 'Test-IsLocalMachine' -ParameterFilter { $Scope -eq $customDomain } @@ -1967,7 +1973,7 @@ try $disposables = New-Object -TypeName 'System.Collections.ArrayList' $customDomain = 'CustomDomain' - + $userNameWithDomain = 'CustomDomain\username' $testPassword = 'TestPassword' $secureTestPassword = ConvertTo-SecureString -String $testPassword -AsPlainText -Force @@ -1989,22 +1995,22 @@ try It 'Should return a custom principal context from the cache' { $customDomain = 'CustomDomain' - + $principalContextCache = @{ $customDomain = $script:testPrincipalContext } $disposables = New-Object -TypeName 'System.Collections.ArrayList' - + Get-PrincipalContext -Scope $customDomain -PrincipalContextCache $principalContextCache -Disposables $disposables Assert-MockCalled -CommandName 'Test-IsLocalMachine' -ParameterFilter { $Scope -eq $customDomain } Assert-MockCalled -CommandName 'New-Object' -ParameterFilter { $TypeName -eq 'System.DirectoryServices.AccountManagement.PrincipalContext' } -Times 0 -Scope 'It' - + $principalContextCache.$customDomain | Should Not Be $fakePrincipalContext $disposables.Contains($fakePrincipalContext) | Should Be $false } } } - + } } } diff --git a/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 b/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 index 28729fc10..2f562717d 100644 --- a/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 +++ b/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + Describe 'xMsiPackage Unit Tests' { BeforeAll { # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment diff --git a/Tests/Unit/MSFT_xPackageResource.Tests.ps1 b/Tests/Unit/MSFT_xPackageResource.Tests.ps1 index 665bf4e8b..bfd9c927d 100644 --- a/Tests/Unit/MSFT_xPackageResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xPackageResource.Tests.ps1 @@ -1,5 +1,12 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $script:testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' + +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + Import-Module -Name $script:commonTestHelperFilePath $script:testEnvironment = Enter-DscResourceTestEnvironment ` diff --git a/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 b/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 index d8ea95eb7..36726704d 100644 --- a/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' @@ -18,7 +24,7 @@ try $script:validRegistryDriveRoots = @( 'HKEY_CLASSES_ROOT', 'HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE', 'HKEY_USERS', 'HKEY_CURRENT_CONFIG' ) $script:validRegistryDriveNames = @( 'HKCR', 'HKCU', 'HKLM', 'HKUS', 'HKCC' ) - + # This registry key is used ONLY for its type (Microsoft.Win32.RegistryKey). It is not actually accessed in any way during these tests. $script:testRegistryKey = [Microsoft.Win32.Registry]::CurrentConfig @@ -37,7 +43,7 @@ try Key = 'TestRegistryKey' ValueName = '' } - + It 'Should not throw' { { $null = Get-TargetResource @getTargetResourceParameters } | Should Not Throw } @@ -97,7 +103,7 @@ try $getTargetResourceResult.ValueData | Should Be $null } } - + Mock -CommandName 'Get-RegistryKey' -MockWith { return $script:testRegistryKey } Context 'Specified registry key exists, registry key value name specified as an empty string, and registry key value data and type not specified' { @@ -105,7 +111,7 @@ try Key = 'TestRegistryKey' ValueName = '' } - + It 'Should not throw' { { $null = Get-TargetResource @getTargetResourceParameters } | Should Not Throw } @@ -171,7 +177,7 @@ try Key = 'TestRegistryKey' ValueName = 'TestValueName' } - + It 'Should not throw' { { $null = Get-TargetResource @getTargetResourceParameters } | Should Not Throw } @@ -254,7 +260,7 @@ try Key = 'TestRegistryKey' ValueName = 'TestValueName' } - + It 'Should not throw' { { $null = Get-TargetResource @getTargetResourceParameters } | Should Not Throw } @@ -347,7 +353,7 @@ try ValueType = 'String' ValueData = 'TestValueData' } - + It 'Should not throw' { { $null = Get-TargetResource @getTargetResourceParameters } | Should Not Throw } @@ -1016,7 +1022,7 @@ try Set-TargetResource @setTargetResourceParameters | Should Be $null } } - + Context 'Registry key exists, Ensure specified as Present, specified registry value does not exist, and registry value type and data not specified' { $setTargetResourceParameters = @{ Key = 'TestRegistryKey' @@ -1061,7 +1067,7 @@ try It 'Should convert the specified registry key value to a string' { $convertToStringParameterFilter = { - $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $script:defaultValueData -DifferenceObject $RegistryKeyValue) + $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $script:defaultValueData -DifferenceObject $RegistryKeyValue) return $registryKeyValueParameterCorrect } @@ -1181,7 +1187,7 @@ try It 'Should convert the specified registry key value to binary data' { $convertToBinaryParameterFilter = { - $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $setTargetResourceParameters.ValueData -DifferenceObject $RegistryKeyValue) + $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $setTargetResourceParameters.ValueData -DifferenceObject $RegistryKeyValue) return $registryKeyValueParameterCorrect } @@ -1311,7 +1317,7 @@ try It 'Should convert the specified registry key value to a multi-string' { $convertToMultiStringParameterFilter = { - $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $setTargetResourceParameters.ValueData -DifferenceObject $RegistryKeyValue) + $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $setTargetResourceParameters.ValueData -DifferenceObject $RegistryKeyValue) return $registryKeyValueParameterCorrect } @@ -1438,9 +1444,9 @@ try It 'Should convert the specified registry key value to a dword' { $convertToDwordParameterFilter = { - $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $setTargetResourceParameters.ValueData -DifferenceObject $RegistryKeyValue) + $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $setTargetResourceParameters.ValueData -DifferenceObject $RegistryKeyValue) $hexParameterCorrect = $Hex -eq $setTargetResourceParameters.Hex - + return $registryKeyValueParameterCorrect -and $hexParameterCorrect } @@ -1570,9 +1576,9 @@ try It 'Should convert the specified registry key value to a qword' { $convertToQwordParameterFilter = { - $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $setTargetResourceParameters.ValueData -DifferenceObject $RegistryKeyValue) + $registryKeyValueParameterCorrect = $null -eq (Compare-Object -ReferenceObject $setTargetResourceParameters.ValueData -DifferenceObject $RegistryKeyValue) $hexParameterCorrect = $Hex -eq $setTargetResourceParameters.Hex - + return $registryKeyValueParameterCorrect -and $hexParameterCorrect } @@ -1846,7 +1852,7 @@ try } } } - + Describe 'xRegistry\Test-TargetResource' { Mock -CommandName 'Get-RegistryKeyValueDisplayName' -MockWith { return $RegistryKeyValueName } Mock -CommandName 'Test-RegistryKeyValuesMatch' -MockWith { return $true } @@ -2783,7 +2789,7 @@ try $mountRegistryDriveParameters = @{ RegistryDriveName = 'TestRegistryDriveName' } - + It 'Should throw error for unmountable registry drive' { $errorMessage = $script:localizedData.RegistryDriveCouldNotBeMounted -f $mountRegistryDriveParameters.RegistryDriveName @@ -2797,7 +2803,7 @@ try $mountRegistryDriveParameters = @{ RegistryDriveName = 'TestRegistryDriveName' } - + It 'Should throw error for unmountable registry drive' { $errorMessage = $script:localizedData.RegistryDriveCouldNotBeMounted -f $mountRegistryDriveParameters.RegistryDriveName @@ -2811,7 +2817,7 @@ try $mountRegistryDriveParameters = @{ RegistryDriveName = 'TestRegistryDriveName' } - + It 'Should throw error for unmountable registry drive' { $errorMessage = $script:localizedData.RegistryDriveCouldNotBeMounted -f $mountRegistryDriveParameters.RegistryDriveName @@ -2825,7 +2831,7 @@ try $mountRegistryDriveParameters = @{ RegistryDriveName = 'HKCR' } - + $expectedRegistryDriveRoot = 'HKEY_CLASSES_ROOT' It 'Should not throw' { @@ -2847,7 +2853,7 @@ try $rootParameterCorrect = $Root -eq $expectedRegistryDriveRoot $psProviderParameterCorrect = $PSProvider -eq 'Registry' $scopeParameterCorrect = $Scope -eq 'Script' - + return $nameParameterCorrect -and $rootParameterCorrect -and $psProviderParameterCorrect -and $scopeParameterCorrect } @@ -2865,7 +2871,7 @@ try $mountRegistryDriveParameters = @{ RegistryDriveName = 'TestRegistryDriveName' } - + It 'Should throw error for unmountable registry drive' { $errorMessage = $script:localizedData.RegistryDriveCouldNotBeMounted -f $mountRegistryDriveParameters.RegistryDriveName @@ -2879,7 +2885,7 @@ try $mountRegistryDriveParameters = @{ RegistryDriveName = 'TestRegistryDriveName' } - + It 'Should throw error for unmountable registry drive' { $errorMessage = $script:localizedData.RegistryDriveCouldNotBeMounted -f $mountRegistryDriveParameters.RegistryDriveName @@ -2893,7 +2899,7 @@ try $mountRegistryDriveParameters = @{ RegistryDriveName = 'HKCR' } - + $expectedRegistryDriveRoot = 'HKEY_CLASSES_ROOT' It 'Should not throw' { @@ -3223,7 +3229,7 @@ try $convertToReadableStringResult | Should Be ([String]::Empty) } } - + Context "Registry key value specified as an empty array and registry key type specified as $registryKeyValueType" { $convertToReadableStringParameters = @{ RegistryKeyValue = @() diff --git a/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 b/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 index 1ae20fe59..301ce997a 100644 --- a/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 +++ b/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 @@ -1,6 +1,12 @@ $Global:DSCModuleName = 'xPSDesiredStateConfiguration' $Global:DSCResourceName = 'MSFT_xRemoteFile' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + #region HEADER # Unit Test Template Version: 1.1.0 [String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) @@ -14,7 +20,7 @@ Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHel $TestEnvironment = Initialize-TestEnvironment ` -DSCModuleName $Global:DSCModuleName ` -DSCResourceName $Global:DSCResourceName ` - -TestType Unit + -TestType Unit #endregion HEADER # Create a working folder that all files will be created in @@ -39,11 +45,11 @@ try [System.String] $errorMessage ) - + $errorCategory = [System.Management.Automation.ErrorCategory]::InvalidData $exception = New-Object ` -TypeName System.InvalidOperationException ` - -ArgumentList $errorMessage + -ArgumentList $errorMessage $errorRecord = New-Object ` -TypeName System.Management.Automation.ErrorRecord ` -ArgumentList $exception, $errorId, $errorCategory, $null diff --git a/Tests/Unit/MSFT_xScriptResource.Tests.ps1 b/Tests/Unit/MSFT_xScriptResource.Tests.ps1 index 7e45dbe43..4c5afa76f 100644 --- a/Tests/Unit/MSFT_xScriptResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xScriptResource.Tests.ps1 @@ -1,6 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' @@ -77,7 +83,7 @@ try { TestScript = 'NotUsed' SetScript = 'NotUsed' } - + It 'Should not throw' { { $null = Get-TargetResource @getTargetResourceParameters } | Should Not Throw } @@ -94,7 +100,7 @@ try { Assert-MockCalled -CommandName 'Invoke-Script' -ParameterFilter $invokeScriptParameterFilter -Times 1 -Scope 'It' } - + It 'Should return a hashtable' { $getTargetResourceResult = Get-TargetResource @getTargetResourceParameters $getTargetResourceResult -is [Hashtable] | Should Be $true @@ -113,7 +119,7 @@ try { SetScript = 'NotUsed' Credential = $script:testCredenital } - + It 'Should not throw' { { $null = Get-TargetResource @getTargetResourceParameters } | Should Not Throw } @@ -126,13 +132,13 @@ try { $invokeScriptParameterFilter = { $scriptBlockParameterCorrect = $null -eq (Compare-Object -ReferenceObject $expectedScriptBlock.Ast -DifferenceObject $ScriptBlock.Ast) $credentialParameterCorrect = $null -eq (Compare-Object -ReferenceObject $getTargetResourceParameters.Credential -DifferenceObject $Credential) - - return $scriptBlockParameterCorrect -and $credentialParameterCorrect + + return $scriptBlockParameterCorrect -and $credentialParameterCorrect } Assert-MockCalled -CommandName 'Invoke-Script' -ParameterFilter $invokeScriptParameterFilter -Times 1 -Scope 'It' } - + It 'Should return a hashtable' { $getTargetResourceResult = Get-TargetResource @getTargetResourceParameters $getTargetResourceResult -is [Hashtable] | Should Be $true @@ -193,8 +199,8 @@ try { $invokeScriptParameterFilter = { $scriptBlockParameterCorrect = $null -eq (Compare-Object -ReferenceObject $expectedScriptBlock.Ast -DifferenceObject $ScriptBlock.Ast) $credentialParameterCorrect = $null -eq (Compare-Object -ReferenceObject $setTargetResourceParameters.Credential -DifferenceObject $Credential) - - return $scriptBlockParameterCorrect -and $credentialParameterCorrect + + return $scriptBlockParameterCorrect -and $credentialParameterCorrect } Assert-MockCalled -CommandName 'Invoke-Script' -ParameterFilter $invokeScriptParameterFilter -Times 1 -Scope 'It' @@ -280,7 +286,7 @@ try { Assert-MockCalled -CommandName 'Invoke-Script' -ParameterFilter $invokeScriptParameterFilter -Times 1 -Scope 'It' } - + It 'Should return the expected boolean' { $testTargetResourceResult = Test-TargetResource @testTargetResourceParameters $testTargetResourceResult | Should Be $expectedBoolean @@ -307,13 +313,13 @@ try { $invokeScriptParameterFilter = { $scriptBlockParameterCorrect = $null -eq (Compare-Object -ReferenceObject $expectedScriptBlock.Ast -DifferenceObject $ScriptBlock.Ast) $credentialParameterCorrect = $null -eq (Compare-Object -ReferenceObject $testTargetResourceParameters.Credential -DifferenceObject $Credential) - - return $scriptBlockParameterCorrect -and $credentialParameterCorrect + + return $scriptBlockParameterCorrect -and $credentialParameterCorrect } Assert-MockCalled -CommandName 'Invoke-Script' -ParameterFilter $invokeScriptParameterFilter -Times 1 -Scope 'It' } - + It 'Should return the expected boolean' { $testTargetResourceResult = Test-TargetResource @testTargetResourceParameters $testTargetResourceResult | Should Be $expectedBoolean @@ -346,7 +352,7 @@ try { Assert-MockCalled -CommandName 'Invoke-Script' -ParameterFilter $invokeScriptParameterFilter -Times 1 -Scope 'It' } - + It 'Should return the expected boolean' { $testTargetResourceResult = Test-TargetResource @testTargetResourceParameters $testTargetResourceResult | Should Be $expectedBoolean @@ -443,7 +449,7 @@ try { It 'Should return result of script' { $scriptExecutionHelperResult = Invoke-Script @scriptExecutionHelperParameters $scriptExecutionHelperResult | Should Be $testScriptResult - } + } } } } diff --git a/Tests/Unit/MSFT_xServiceResource.Tests.ps1 b/Tests/Unit/MSFT_xServiceResource.Tests.ps1 index ec95c9f68..52268bd36 100644 --- a/Tests/Unit/MSFT_xServiceResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xServiceResource.Tests.ps1 @@ -2,6 +2,12 @@ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' diff --git a/Tests/Unit/MSFT_xUserResource.Tests.ps1 b/Tests/Unit/MSFT_xUserResource.Tests.ps1 index 8e2c0f2a9..0ad41ff8b 100644 --- a/Tests/Unit/MSFT_xUserResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xUserResource.Tests.ps1 @@ -2,6 +2,12 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force @@ -21,31 +27,31 @@ try { InModuleScope 'MSFT_xUserResource' { # Used to skip the Nano server tests for the time being since they are not working on AppVeyor - + $script:skipMe = $true - + $existingUserName = 'TestUserName12345' $existingUserPassword = 'StrongOne7.' $existingDescription = 'Some Description' $existingSecurePassword = ConvertTo-SecureString $existingUserPassword -AsPlainText -Force $existingTestCredential = New-Object PSCredential ($existingUserName, $existingSecurePassword) - + New-User -Credential $existingTestCredential -Description $existingDescription - + $newUserName1 = 'NewTestUserName12345' $newUserPassword1 = 'NewStrongOne123.' $newFullName1 = 'Fullname1' $newUserDescription1 = 'New Description1' $newSecurePassword1 = ConvertTo-SecureString $newUserPassword1 -AsPlainText -Force $newCredential1 = New-Object PSCredential ($newUserName1, $newSecurePassword1) - + $newUserName2 = 'newUser1234' $newPassword2 = 'ThisIsAStrongPassword543!' $newFullName2 = 'Fullname2' $newUserDescription2 = 'New Description2' $newSecurePassword2 = ConvertTo-SecureString $newPassword2 -AsPlainText -Force $newCredential2 = New-Object PSCredential ($newUserName2, $newSecurePassword2) - + try { Describe 'xUserResource/Get-TargetResource' { @@ -94,28 +100,28 @@ try { Describe 'xUserResource/Set-TargetResource' { Context 'Tests on FullSKU' { Mock -CommandName Test-IsNanoServer -MockWith { return $false } - + try { New-User -Credential $newCredential1 -Description $newUserDescription1 - + It 'Should remove the user' { Test-User -UserName $newUserName1 | Should Be $true Set-TargetResource -UserName $newUserName1 -Ensure 'Absent' Test-User -UserName $newUserName1 | Should Be $false } - + It 'Should add the new user' { Set-TargetResource -UserName $newUserName2 -Password $newCredential2 -Ensure 'Present' Test-User -UserName $newUserName2 | Should Be $true } - + It 'Should update the user' { $disabled = $false $passwordNeverExpires = $true $passwordChangeRequired = $false $passwordChangeNotAllowed = $true - + Set-TargetResource -UserName $newUserName2 ` -Password $newCredential2 ` -Ensure 'Present' ` @@ -125,9 +131,9 @@ try { -PasswordNeverExpires $passwordNeverExpires ` -PasswordChangeRequired $passwordChangeRequired ` -PasswordChangeNotAllowed $passwordChangeNotAllowed - + Test-User -UserName $newUserName2 | Should Be $true - $testTargetResourceResult1 = + $testTargetResourceResult1 = Test-TargetResource -UserName $newUserName2 ` -Password $newCredential2 ` -Ensure 'Present' ` @@ -143,7 +149,7 @@ try { $passwordNeverExpires = $false $passwordChangeRequired = $true $passwordChangeNotAllowed = $false - + Set-TargetResource -UserName $newUserName2 ` -Password $newCredential1 ` -Ensure 'Present' ` @@ -153,9 +159,9 @@ try { -PasswordNeverExpires $passwordNeverExpires ` -PasswordChangeRequired $passwordChangeRequired ` -PasswordChangeNotAllowed $passwordChangeNotAllowed - + Test-User -UserName $newUserName2 | Should Be $true - $testTargetResourceResult2 = + $testTargetResourceResult2 = Test-TargetResource -UserName $newUserName2 ` -Password $newCredential1 ` -Ensure 'Present' ` @@ -177,28 +183,28 @@ try { Context 'Tests on Nano Server' { Mock -CommandName Test-IsNanoServer -MockWith { return $true } Mock -CommandName Test-CredentialsValidOnNanoServer { return $true } - + try { New-User -Credential $newCredential1 -Description $newUserDescription1 - + It 'Should remove the user' -Skip:$script:skipMe { Test-User -UserName $newUserName1 | Should Be $true Set-TargetResource -UserName $newUserName1 -Ensure 'Absent' Test-User -UserName $newUserName1 | Should Be $false } - + It 'Should add the new user' -Skip:$script:skipMe { Set-TargetResource -UserName $newUserName2 -Password $newCredential2 -Ensure 'Present' Test-User -UserName $newUserName2 | Should Be $true } - + It 'Should update the user' -Skip:$script:skipMe { $disabled = $false $passwordNeverExpires = $true $passwordChangeRequired = $false $passwordChangeNotAllowed = $true - + Set-TargetResource -UserName $newUserName2 ` -Password $newCredential2 ` -Ensure 'Present' ` @@ -208,9 +214,9 @@ try { -PasswordNeverExpires $passwordNeverExpires ` -PasswordChangeRequired $passwordChangeRequired ` -PasswordChangeNotAllowed $passwordChangeNotAllowed - + Test-User -UserName $newUserName2 | Should Be $true - $testTargetResourceResult1 = + $testTargetResourceResult1 = Test-TargetResource -UserName $newUserName2 ` -Password $newCredential2 ` -Ensure 'Present' ` @@ -226,7 +232,7 @@ try { $passwordNeverExpires = $false $passwordChangeRequired = $true $passwordChangeNotAllowed = $false - + Set-TargetResource -UserName $newUserName2 ` -Password $newCredential1 ` -Ensure 'Present' ` @@ -236,9 +242,9 @@ try { -PasswordNeverExpires $passwordNeverExpires ` -PasswordChangeRequired $passwordChangeRequired ` -PasswordChangeNotAllowed $passwordChangeNotAllowed - + Test-User -UserName $newUserName2 | Should Be $true - $testTargetResourceResult2 = + $testTargetResourceResult2 = Test-TargetResource -UserName $newUserName2 ` -Password $newCredential1 ` -Ensure 'Present' ` @@ -262,7 +268,7 @@ try { Context 'Tests on FullSKU' { Mock -CommandName Test-IsNanoServer -MockWith { return $false } $absentUserName = 'AbsentUserUserName123456789' - + It 'Should return true when user Present and correct values' { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Description $existingDescription ` @@ -272,7 +278,7 @@ try { -PasswordChangeNotAllowed $false $testTargetResourceResult | Should Be $true } - + It 'Should return true when user Absent and Ensure = Absent' { $testTargetResourceResult = Test-TargetResource -UserName $absentUserName ` -Ensure 'Absent' @@ -284,23 +290,23 @@ try { -Ensure 'Present' $testTargetResourceResult | Should Be $false } - + It 'Should return false when user Present and Ensure = Absent' { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Ensure 'Absent' $testTargetResourceResult | Should Be $false } - + It 'Should return false when Password is wrong' { $badPassword = 'WrongPassword' $secureBadPassword = ConvertTo-SecureString $badPassword -AsPlainText -Force $badTestCredential = New-Object PSCredential ($existingUserName, $secureBadPassword) - + $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Password $badTestCredential $testTargetResourceResult | Should Be $false } - + It 'Should return false when user Present and wrong Description' { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Description 'Wrong description' @@ -310,36 +316,36 @@ try { It 'Should return false when FullName is incorrect' { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -FullName 'Wrong FullName' - $testTargetResourceResult | Should Be $false + $testTargetResourceResult | Should Be $false } - + It 'Should return false when Disabled is incorrect' { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Disabled $true - $testTargetResourceResult | Should Be $false + $testTargetResourceResult | Should Be $false } - + It 'Should return false when PasswordNeverExpires is incorrect' { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -PasswordNeverExpires $true - $testTargetResourceResult | Should Be $false + $testTargetResourceResult | Should Be $false } - + It 'Should return false when PasswordChangeNotAllowed is incorrect' { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -PasswordChangeNotAllowed $true - $testTargetResourceResult | Should Be $false + $testTargetResourceResult | Should Be $false } } - + Context 'Tests on Nano Server' { Mock -CommandName Test-IsNanoServer -MockWith { return $true } - + $absentUserName = 'AbsentUserUserName123456789' - + It 'Should return true when user Present and correct values' -Skip:$script:skipMe { Mock -CommandName Test-CredentialsValidOnNanoServer { return $true } - + $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Description $existingDescription ` -Password $existingTestCredential ` @@ -348,7 +354,7 @@ try { -PasswordChangeNotAllowed $false $testTargetResourceResult | Should Be $true } - + It 'Should return true when user Absent and Ensure = Absent' -Skip:$script:skipMe { $testTargetResourceResult = Test-TargetResource -UserName $absentUserName ` -Ensure 'Absent' @@ -360,25 +366,25 @@ try { -Ensure 'Present' $testTargetResourceResult | Should Be $false } - + It 'Should return false when user Present and Ensure = Absent' -Skip:$script:skipMe { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Ensure 'Absent' $testTargetResourceResult | Should Be $false } - + It 'Should return false when Password is wrong' -Skip:$script:skipMe { Mock -CommandName Test-CredentialsValidOnNanoServer { return $false } - + $badPassword = 'WrongPassword' $secureBadPassword = ConvertTo-SecureString $badPassword -AsPlainText -Force $badTestCredential = New-Object PSCredential ($existingUserName, $secureBadPassword) - + $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Password $badTestCredential $testTargetResourceResult | Should Be $false } - + It 'Should return false when user Present and wrong Description' -Skip:$script:skipMe { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Description 'Wrong description' @@ -388,34 +394,34 @@ try { It 'Should return false when FullName is incorrect' -Skip:$script:skipMe { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -FullName 'Wrong FullName' - $testTargetResourceResult | Should Be $false + $testTargetResourceResult | Should Be $false } - + It 'Should return false when Disabled is incorrect' -Skip:$script:skipMe { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -Disabled $true - $testTargetResourceResult | Should Be $false + $testTargetResourceResult | Should Be $false } - + It 'Should return false when PasswordNeverExpires is incorrect' -Skip:$script:skipMe { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -PasswordNeverExpires $true - $testTargetResourceResult | Should Be $false + $testTargetResourceResult | Should Be $false } - + It 'Should return false when PasswordChangeNotAllowed is incorrect' -Skip:$script:skipMe { $testTargetResourceResult = Test-TargetResource -UserName $existingUserName ` -PasswordChangeNotAllowed $true - $testTargetResourceResult | Should Be $false + $testTargetResourceResult | Should Be $false } } } - + Describe 'xUserResource/Assert-UserNameValid' { It 'Should not throw when username contains all valid chars' { { Assert-UserNameValid -UserName 'abc123456!f_t-l098s' } | Should Not Throw } - + It 'Should throw InvalidArgumentError when username contains only whitespace and dots' { $invalidName = ' . .. . ' $errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument @@ -425,7 +431,7 @@ try { $errorRecord = New-Object System.Management.Automation.ErrorRecord $exception, $errorId, $errorCategory, $null { Assert-UserNameValid -UserName $invalidName } | Should Throw $errorRecord } - + It 'Should throw InvalidArgumentError when username contains an invalid char' { $invalidName = 'user|name' $errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument diff --git a/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 b/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 index defbc825a..0f5ac60e1 100644 --- a/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 @@ -2,6 +2,12 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force @@ -27,12 +33,12 @@ try { $mockWindowsFeatures = @{ - Test1 = @{ + Test1 = @{ Name = 'Test1' DisplayName = 'Test Feature 1' Description = 'Test Feature with 3 subfeatures' - Installed = $false - InstallState = 'Available' + Installed = $false + InstallState = 'Available' FeatureType = 'Role Service' Path = 'Test1' Depth = 1 @@ -48,7 +54,7 @@ try { AdditionalInfo = @('MajorVersion', 'MinorVersion', 'NumericId', 'InstallName') } - SubTest1 = @{ + SubTest1 = @{ Name = 'SubTest1' DisplayName = 'Sub Test Feature 1' Description = 'Sub Test Feature with parent as test1' @@ -69,7 +75,7 @@ try { AdditionalInfo = @('MajorVersion', 'MinorVersion', 'NumericId', 'InstallName') } - SubTest2 = @{ + SubTest2 = @{ Name = 'SubTest2' DisplayName = 'Sub Test Feature 2' Description = 'Sub Test Feature with parent as test1' @@ -111,12 +117,12 @@ try { AdditionalInfo = @('MajorVersion', 'MinorVersion', 'NumericId', 'InstallName') } - Test2 = @{ + Test2 = @{ Name = 'Test2' DisplayName = 'Test Feature 2' Description = 'Test Feature with 0 subfeatures' - Installed = $true - InstallState = 'Available' + Installed = $true + InstallState = 'Available' FeatureType = 'Role Service' Path = 'Test2' Depth = 1 @@ -141,7 +147,7 @@ try { $windowsFeature = $mockWindowsFeatures[$testWindowsFeatureName2] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -149,7 +155,7 @@ try { $windowsFeature = $mockWindowsFeatures[$testWindowsFeatureName1] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -157,7 +163,7 @@ try { $windowsFeature = $mockWindowsFeatures[$testSubFeatureName1] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -165,7 +171,7 @@ try { $windowsFeature = $mockWindowsFeatures[$testSubFeatureName2] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -173,13 +179,13 @@ try { $windowsFeature = $mockWindowsFeatures[$testSubFeatureName3] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } - + Context 'Windows Feature exists with no sub features' { - + It 'Should return the correct hashtable when not on a 2008 Server' { Mock -CommandName Test-IsWinServer2008R2SP1 -MockWith { return $false } @@ -202,11 +208,11 @@ try { It 'Should return the correct hashtable when on a 2008 Server and Credential is passed' { Mock -CommandName Test-IsWinServer2008R2SP1 -MockWith { return $true } - Mock -CommandName Invoke-Command -MockWith { + Mock -CommandName Invoke-Command -MockWith { $windowsFeature = $mockWindowsFeatures[$testWindowsFeatureName2] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -259,7 +265,7 @@ try { } } } - + Describe 'xWindowsFeature/Set-TargetResource' { Mock -CommandName Import-ServerManager -MockWith {} @@ -275,7 +281,7 @@ try { } $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -288,7 +294,7 @@ try { } $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -316,7 +322,7 @@ try { } $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -329,18 +335,18 @@ try { } $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } It 'Should throw invalid operation exception when Ensure set to Present' { - { Set-TargetResource -Name $testWindowsFeatureName2 -Ensure 'Present' } | + { Set-TargetResource -Name $testWindowsFeatureName2 -Ensure 'Present' } | Should Throw ($script:localizedData.FeatureInstallationFailureError -f $testWindowsFeatureName2) Assert-MockCalled -CommandName Add-WindowsFeature -Times 1 -Exactly -Scope It } It 'Should throw invalid operation exception when Ensure set to Absent' { - { Set-TargetResource -Name $testWindowsFeatureName2 -Ensure 'Absent' } | + { Set-TargetResource -Name $testWindowsFeatureName2 -Ensure 'Absent' } | Should Throw ($script:localizedData.FeatureUninstallationFailureError -f $testWindowsFeatureName2) Assert-MockCalled -CommandName Remove-WindowsFeature -Times 1 -Exactly -Scope It } @@ -359,7 +365,7 @@ try { } $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -368,7 +374,7 @@ try { It 'Should install the feature when Ensure set to Present and Credential passed in' { - { + { Set-TargetResource -Name $testWindowsFeatureName2 ` -Ensure 'Present' ` -Credential $testCredential @@ -379,7 +385,7 @@ try { It 'Should uninstall the feature when Ensure set to Absent and Credential passed in' { - { + { Set-TargetResource -Name $testWindowsFeatureName2 ` -Ensure 'Absent' ` -Credential $testCredential @@ -397,7 +403,7 @@ try { $windowsFeature = $mockWindowsFeatures[$testWindowsFeatureName1] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -405,7 +411,7 @@ try { $windowsFeature = $mockWindowsFeatures[$testSubFeatureName1] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -413,7 +419,7 @@ try { $windowsFeature = $mockWindowsFeatures[$testSubFeatureName2] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -421,7 +427,7 @@ try { $windowsFeature = $mockWindowsFeatures[$testSubFeatureName3] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -430,7 +436,7 @@ try { $windowsFeature = $mockWindowsFeatures[$testWindowsFeatureName1] $windowsFeatureObject = New-Object -TypeName PSObject -Property $windowsFeature $windowsFeatureObject.PSTypeNames[0] = 'Microsoft.Windows.ServerManager.Commands.Feature' - + return $windowsFeatureObject } @@ -562,12 +568,12 @@ try { It 'Should throw invalid operation when feature equals null' { $nonexistentName = 'NonexistentFeatureName' - { Assert-SingleFeatureExists -Feature $null -Name $nonexistentName } | + { Assert-SingleFeatureExists -Feature $null -Name $nonexistentName } | Should Throw ($script:localizedData.FeatureNotFoundError -f $nonexistentName) } It 'Should throw invalid operation when there are multiple features with the given name' { - { Assert-SingleFeatureExists -Feature $multipleFeature -Name $multipleFeature.Name } | + { Assert-SingleFeatureExists -Feature $multipleFeature -Name $multipleFeature.Name } | Should Throw ($script:localizedData.MultipleFeatureInstancesError -f $multipleFeature.Name) } } @@ -584,14 +590,14 @@ try { Mock -CommandName Import-Module -MockWith {} { Import-ServerManager } | Should Not Throw } - + It 'Should Not Throw when exception is Identity Reference Runtime Exception' { $mockIdentityReferenceRuntimeException = New-Object -TypeName System.Management.Automation.RuntimeException -ArgumentList 'Some or all identity references could not be translated' Mock -CommandName Import-Module -MockWith { Throw $mockIdentityReferenceRuntimeException } { Import-ServerManager } | Should Not Throw } - + It 'Should throw invalid operation exception when exception is not Identity Reference Runtime Exception' { $mockOtherRuntimeException = New-Object -TypeName System.Management.Automation.RuntimeException -ArgumentList 'Other error' Mock -CommandName Import-Module -MockWith { Throw $mockOtherRuntimeException } diff --git a/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 b/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 index 995801664..43affe95d 100644 --- a/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 @@ -1,5 +1,11 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xWindowsOptionalFeature' ` @@ -14,7 +20,7 @@ try $script:testFeatureName = 'TestFeature' - $script:fakeEnabledFeature = [PSCustomObject] @{ + $script:fakeEnabledFeature = [PSCustomObject] @{ Name = $testFeatureName State = 'Enabled' } @@ -27,7 +33,7 @@ try <# This context block needs to stay at the top because of a bug in Pester on Nano server. - + Assert-ResourcePrerequisitesValid is mocked in most of the other contexts blocks. This causes errors to throw from the script blocks in this context since this function does not take any parameters, but Pester tries to pipe something into it. @@ -57,7 +63,7 @@ try BuildNumber = 9600 } } - + It 'Should throw when the DISM module is not available' { Mock Import-Module -ParameterFilter { $Name -eq 'Dism' } -MockWith { Write-Error 'Cannot find module' } { Assert-ResourcePrerequisitesValid } | Should Throw $script:localizedData.DismNotAvailable @@ -111,7 +117,7 @@ try } } - + Context 'Get-TargetResource - Feature Disabled' { Mock Assert-ResourcePrerequisitesValid -MockWith { } Mock Dism\Get-WindowsOptionalFeature { $FeatureName -eq $script:testFeatureName } -MockWith { return $script:fakeDisabledFeature } @@ -167,9 +173,9 @@ try It 'Should call Enable-WindowsOptionalFeature with NoRestart set to true by default when Ensure set to Present' { Mock Dism\Enable-WindowsOptionalFeature -ParameterFilter { $NoRestart -eq $true } -MockWith { } - + Set-TargetResource -Name $script:testFeatureName - + Assert-MockCalled Dism\Enable-WindowsOptionalFeature -ParameterFilter { $NoRestart -eq $true } -Scope It } @@ -306,7 +312,7 @@ try It 'Should return the correct string for each object' { $propertiesAsStrings = Convert-CustomPropertyArrayToStringArray -CustomProperties $psCustomObjects - + foreach ($objectNumber in @(1, 2, 3)) { $propertiesAsStrings.Contains("Name = Object $objectNumber, Value = Value $objectNumber, Path = Path $objectNumber") | Should Be $true diff --git a/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 b/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 index 1284b7d39..1c5dee622 100644 --- a/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 @@ -1,5 +1,11 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xWindowsPackageCab' ` diff --git a/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 b/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 index abd19f8b8..403fba3b6 100644 --- a/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 @@ -1,6 +1,12 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -89,10 +95,10 @@ try Describe 'xWindowsProcess\Get-TargetResource' { Mock -CommandName Expand-Path -MockWith { return $Path } - Mock -CommandName Get-ProcessCimInstance -MockWith { + Mock -CommandName Get-ProcessCimInstance -MockWith { if ($Path -eq $script:validPath1) { - return @($script:mockProcess1, $script:mockProcess3) + return @($script:mockProcess1, $script:mockProcess3) } elseif ($Path -eq $script:validPath2) { @@ -110,7 +116,7 @@ try Mock -CommandName Get-Process -MockWith { if ($ID -eq $script:mockProcess1.Id) { - return $script:mockProcess1 + return $script:mockProcess1 } elseif ($script:mockProcess2.Id) { @@ -127,27 +133,27 @@ try } Mock -CommandName New-InvalidOperationException -MockWith { Throw $script:exceptionMessage } Mock -CommandName New-InvalidArgumentException -MockWith { Throw $script:exceptionMessage } - + It 'Should return the correct properties for a process that is Absent' { $processArguments = 'TestGetProperties' - + $getTargetResourceResult = Get-TargetResource -Path $invalidPath ` -Arguments $processArguments - + $getTargetResourceResult.Arguments | Should Be $processArguments $getTargetResourceResult.Ensure | Should Be 'Absent' $getTargetResourceResult.Path | Should Be $invalidPath - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It } - + It 'Should return the correct properties for one process with a credential' { - + $getTargetResourceResult = Get-TargetResource -Path $script:validPath2 ` -Arguments $script:mockProcess2.Arguments ` -Credential $script:testCredential - + $getTargetResourceResult.VirtualMemorySize | Should Be $script:mockProcess2.VirtualMemorySize64 $getTargetResourceResult.Arguments | Should Be $script:mockProcess2.Arguments $getTargetResourceResult.Ensure | Should Be 'Present' @@ -156,17 +162,17 @@ try $getTargetResourceResult.NonPagedMemorySize | Should Be $script:mockProcess2.NonpagedSystemMemorySize64 $getTargetResourceResult.HandleCount | Should Be $script:mockProcess2.HandleCount $getTargetResourceResult.ProcessId | Should Be $script:mockProcess2.ProcessId - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-Process -Exactly 1 -Scope It } - + It 'Should return the correct properties when there are multiple processes' { - + $getTargetResourceResult = Get-TargetResource -Path $script:validPath1 ` -Arguments $script:mockProcess1.Arguments - + $getTargetResourceResult.VirtualMemorySize | Should Be $script:mockProcess1.VirtualMemorySize64 $getTargetResourceResult.Arguments | Should Be $script:mockProcess1.Arguments $getTargetResourceResult.Ensure | Should Be 'Present' @@ -175,19 +181,19 @@ try $getTargetResourceResult.NonPagedMemorySize | Should Be $script:mockProcess1.NonpagedSystemMemorySize64 $getTargetResourceResult.HandleCount | Should Be $script:mockProcess1.HandleCount $getTargetResourceResult.ProcessId | Should Be $script:mockProcess1.ProcessId - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-Process -Exactly 1 -Scope It } } - + Describe 'xWindowsProcess\Set-TargetResource' { Mock -CommandName Expand-Path -MockWith { return $Path } - Mock -CommandName Get-ProcessCimInstance -MockWith { + Mock -CommandName Get-ProcessCimInstance -MockWith { if ($Path -eq $script:validPath1) { - return @($script:mockProcess1, $script:mockProcess3) + return @($script:mockProcess1, $script:mockProcess3) } elseif ($Path -eq $script:validPath2) { @@ -219,38 +225,38 @@ try -Credential $script:testCredential ` -Ensure 'Absent' } | Should Not Throw - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Stop-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 1 -Scope It } - + It 'Should not throw when Ensure set to Absent and processes are not running' { { Set-TargetResource -Path $script:invalidPath ` -Arguments '' ` -Ensure 'Absent' } | Should Not Throw - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Stop-Process -Exactly 0 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 0 -Scope It } - + It 'Should throw an invalid operation exception when Stop-Process throws an error' { { Set-TargetResource -Path $script:errorProcess.Path ` -Arguments '' ` -Ensure 'Absent' } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Stop-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName New-InvalidOperationException -Exactly 1 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 0 -Scope It } - + Mock -CommandName Wait-ProcessCount -MockWith { return $false } It 'Should throw an invalid operation exception when there is a problem waiting for the processes' { @@ -258,14 +264,14 @@ try -Arguments $script:mockProcess1.Arguments ` -Ensure 'Absent' } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Stop-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 1 -Scope It Assert-MockCalled -CommandName New-InvalidOperationException -Exactly 1 -Scope It } - + Mock -CommandName Wait-ProcessCount -MockWith { return $true } Mock -CommandName Start-ProcessAsLocalSystemUser -MockWith {} @@ -275,14 +281,14 @@ try -Credential $script:testCredential ` -Ensure 'Present' } | Should Not Throw - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Test-IsRunFromLocalSystemUser -Exactly 1 -Scope It Assert-MockCalled -CommandName Start-ProcessAsLocalSystemUser -Exactly 1 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 1 -Scope It } - + Mock -CommandName Start-ProcessAsLocalSystemUser -MockWith {} Mock -CommandName Assert-PathArgumentRooted -MockWith {} Mock -CommandName Assert-PathArgumentValid -MockWith {} @@ -294,7 +300,7 @@ try -WorkingDirectory 'test working directory' ` -Ensure 'Present' } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Test-IsRunFromLocalSystemUser -Exactly 1 -Scope It @@ -304,7 +310,7 @@ try Assert-MockCalled -CommandName Assert-PathArgumentValid -Exactly 1 -Scope It Assert-MockCalled -CommandName New-InvalidArgumentException -Exactly 1 -Scope It } - + $testErrorRecord = 'test Start-ProcessAsLocalSystemUser error record' Mock -CommandName Start-ProcessAsLocalSystemUser -MockWith { Throw $testErrorRecord } @@ -314,14 +320,14 @@ try -Credential $script:testCredential ` -Ensure 'Present' } | Should Throw $testErrorRecord - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Test-IsRunFromLocalSystemUser -Exactly 1 -Scope It Assert-MockCalled -CommandName Start-ProcessAsLocalSystemUser -Exactly 1 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 0 -Scope It } - + Mock -CommandName Start-Process -MockWith {} It 'Should not throw when Ensure set to Present and processes are not running and no credential passed' { @@ -329,13 +335,13 @@ try -Arguments $script:mockProcess1.Arguments ` -Ensure 'Present' } | Should Not Throw - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Start-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 1 -Scope It } - + $mockStartProcessException = New-Object -TypeName 'InvalidOperationException' ` -ArgumentList @('Start-Process test exception') Mock -CommandName Start-Process -MockWith { Throw $mockStartProcessException } @@ -345,14 +351,14 @@ try -Arguments $script:mockProcess1.Arguments ` -Ensure 'Present' } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Start-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 0 -Scope It Assert-MockCalled -CommandName New-InvalidOperationException -Exactly 1 -Scope It } - + Mock -CommandName Wait-ProcessCount -MockWith { return $false } Mock -CommandName Start-Process -MockWith {} @@ -361,13 +367,13 @@ try -Arguments $script:mockProcess1.Arguments ` -Ensure 'Present' } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Start-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 1 -Scope It } - + Mock -CommandName Wait-ProcessCount -MockWith { return $true } It 'Should not throw when Ensure set to Present and processes are already running' { @@ -375,20 +381,20 @@ try -Arguments $script:mockProcess1.Arguments ` -Ensure 'Present' } | Should Not Throw - + Assert-MockCalled -CommandName Expand-Path -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessCimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Start-Process -Exactly 0 -Scope It Assert-MockCalled -CommandName Wait-ProcessCount -Exactly 0 -Scope It } } - + Describe 'xWindowsProcess\Test-TargetResource' { Mock -CommandName Expand-Path -MockWith { return $Path } - Mock -CommandName Get-ProcessCimInstance -MockWith { + Mock -CommandName Get-ProcessCimInstance -MockWith { if ($Path -eq $script:validPath1) { - return @($script:mockProcess1, $script:mockProcess3) + return @($script:mockProcess1, $script:mockProcess3) } elseif ($Path -eq $script:validPath2) { @@ -410,14 +416,14 @@ try -Ensure 'Present' $testTargetResourceResult | Should Be $true } - + It 'Should return false when Ensure set to Present and process is not running' { $testTargetResourceResult = Test-TargetResource -Path $script:invalidPath ` -Arguments $script:mockProcess1.Arguments ` -Ensure 'Present' $testTargetResourceResult | Should Be $false } - + It 'Should return true when Ensure set to Absent and process is not running and Credential passed' { $testTargetResourceResult = Test-TargetResource -Path $script:invalidPath ` -Arguments $script:mockProcess1.Arguments ` @@ -425,46 +431,46 @@ try -Ensure 'Absent' $testTargetResourceResult | Should Be $true } - + It 'Should return false when Ensure set to Absent and process is running' { $testTargetResourceResult = Test-TargetResource -Path $script:validPath1 ` -Arguments $script:mockProcess1.Arguments ` -Ensure 'Absent' $testTargetResourceResult | Should Be $false } - + } - + Describe 'xWindowsProcess\Expand-Path' { Mock -CommandName New-InvalidArgumentException -MockWith { Throw $script:exceptionMessage } Mock -CommandName Test-Path -MockWith { return $true } It 'Should return the original path when path is rooted' { $rootedPath = 'C:\testProcess.exe' - + $expandPathResult = Expand-Path -Path $rootedPath $expandPathResult | Should Be $rootedPath } - + Mock -CommandName Test-Path -MockWith { return $false } It 'Should throw an invalid argument exception when Path is rooted and does not exist' { $rootedPath = 'C:\invalidProcess.exe' - + { Expand-Path -Path $rootedPath} | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName New-InvalidArgumentException -Exactly 1 -Scope It } - + It 'Should throw an invalid argument exception when Path is unrooted and does not exist' { $unrootedPath = 'invalidfile.txt' - + { Expand-Path -Path $unrootedPath} | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName New-InvalidArgumentException -Exactly 1 -Scope It } } - + Describe 'xWindowsProcess\Get-ProcessCimInstance' { Mock -CommandName Get-Process -MockWith { return @($script:mockProcess2) } Mock -CommandName Get-CimInstance -MockWith { return $script:mockProcess2 } @@ -472,11 +478,11 @@ try It 'Should return the correct process when it exists and no arguments passed' { $resultProcess = Get-ProcessCimInstance -Path $script:mockProcess2.Path $resultProcess | Should Be @($script:mockProcess2) - + Assert-MockCalled -CommandName Get-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-CimInstance -Exactly 1 -Scope It } - + Mock -CommandName Get-Process -MockWith { return @($script:mockProcess1) } Mock -CommandName Get-CimInstance -MockWith { return $script:mockProcess1 } @@ -484,11 +490,11 @@ try $resultProcess = Get-ProcessCimInstance -Path $script:mockProcess1.Path ` -Arguments $script:mockProcess1.Arguments $resultProcess | Should Be @($script:mockProcess1) - + Assert-MockCalled -CommandName Get-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-CimInstance -Exactly 1 -Scope It } - + $expectedProcesses = @($script:mockProcess1, $script:mockProcess1, $script:mockProcess1) Mock -CommandName Get-Process -MockWith { return $expectedProcesses } Mock -CommandName Get-CimInstance -MockWith { return $script:mockProcess1 } @@ -496,13 +502,13 @@ try It 'Should return the correct processes when multiple exist' { $resultProcess = Get-ProcessCimInstance -Path $script:mockProcess1.Path ` -Arguments $script:mockProcess1.Arguments - + Compare-Object -ReferenceObject $expectedProcesses -DifferenceObject $resultProcess | Should Be $null - + Assert-MockCalled -CommandName Get-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-CimInstance -Exactly 3 -Scope It } - + Mock -CommandName Get-Process -MockWith { return @($script:mockProcess2, $script:mockProcess2) } Mock -CommandName Get-CimInstance -MockWith { return @($script:mockProcess2, $script:mockProcess2) } @@ -511,11 +517,11 @@ try -Arguments $script:mockProcess2.Arguments ` -UseGetCimInstanceThreshold 1 $resultProcess | Should Be @($script:mockProcess2, $script:mockProcess2) - + Assert-MockCalled -CommandName Get-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-CimInstance -Exactly 1 -Scope It } - + Mock -CommandName Get-Process -MockWith { return @($script:mockProcess2) } Mock -CommandName Get-CimInstance -MockWith { return $script:mockProcess2 } Mock -CommandName Get-ProcessOwner -MockWith { return ($env:computerName + '\' + $script:testUsername) } ` @@ -525,12 +531,12 @@ try $resultProcess = Get-ProcessCimInstance -Path $script:mockProcess2.Path ` -Credential $script:testCredential $resultProcess | Should Be @($script:mockProcess2) - + Assert-MockCalled -CommandName Get-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-CimInstance -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-ProcessOwner -Exactly 1 -Scope It } - + Mock -CommandName Get-Process -MockWith { return @($script:mockProcess3, $script:mockProcess3, $script:mockProcess4, $script:mockProcess2) } Mock -CommandName Get-CimInstance -MockWith { return @($script:mockProcess3, $script:mockProcess3, $script:mockProcess4, $script:mockProcess2) } Mock -CommandName Get-ProcessOwner -MockWith { return ($env:computerName + '\' + $script:testUsername) } ` @@ -544,11 +550,11 @@ try -Arguments $script:mockProcess3.Arguments ` -UseGetCimInstanceThreshold 1 $resultProcess | Should Be @($script:mockProcess3, $script:mockProcess3) - + Assert-MockCalled -CommandName Get-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-CimInstance -Exactly 1 -Scope It } - + Mock -CommandName Get-ProcessOwner -MockWith { return ($env:computerName + '\' + $script:testUsername) } ` -ParameterFilter { ($Process -eq $script:mockProcess3) -or ($Process -eq $script:mockProcess2) } Mock -CommandName Get-ProcessOwner -MockWith { return ('wrongDomain' + '\' + $script:testUsername) } ` @@ -560,26 +566,26 @@ try -Arguments $script:mockProcess3.Arguments ` -UseGetCimInstanceThreshold 1 $resultProcess | Should Be @($script:mockProcess3, $script:mockProcess3) - + Assert-MockCalled -CommandName Get-Process -Exactly 1 -Scope It Assert-MockCalled -CommandName Get-CimInstance -Exactly 1 -Scope It } } - + Describe 'xWindowsProcess\ConvertTo-EscapedStringForWqlFilter' { It 'Should return the same string when there are no escaped characters' { $inputString = 'testString%$.@123' $convertedString = ConvertTo-EscapedStringForWqlFilter -FilterString $inputString $convertedString | Should Be $inputString } - + It 'Should return a string with escaped characters: ("\)' { $inputString = '\test"string"\123' $expectedString = '\\test\"string\"\\123' $convertedString = ConvertTo-EscapedStringForWqlFilter -FilterString $inputString $convertedString | Should Be $expectedString } - + It "Should return a string with escaped characters: ('\)" { $inputString = "\test'string'\123" $expectedString = "\\test\'string\'\\123" @@ -587,47 +593,47 @@ try $convertedString | Should Be $expectedString } } - + Describe 'xWindowsProcess\Get-ProcessOwner' { $mockOwner = @{ Domain = 'Mock Domain' User = 'Mock User' - } + } Mock -CommandName Get-ProcessOwnerCimInstance -MockWith { return $mockOwner } It 'Should return the correct string with domain\user' { $owner = Get-ProcessOwner -Process $script:mockProcess1 $owner | Should Be ($mockOwner.Domain + '\' + $mockOwner.User) } - + It 'Should return the correct string with default-domain\user when domain is not there' { $mockOwner.Domain = $null $owner = Get-ProcessOwner -Process $script:mockProcess1 $owner | Should Be ($env:computerName + '\' + $mockOwner.User) } - + } - - Describe 'xWindowsProcess\Get-ArgumentsFromCommandLineInput' { + + Describe 'xWindowsProcess\Get-ArgumentsFromCommandLineInput' { It 'Should return the correct arguments when single quotes are used' { $inputString = 'test.txt a b c' $argumentsReturned = Get-ArgumentsFromCommandLineInput -CommandLineInput $inputString $argumentsReturned | Should Be 'a b c' } - + It 'Should return the correct arguments when double quotes are used' { $inputString = '"test file test" a b c' $argumentsReturned = Get-ArgumentsFromCommandLineInput -CommandLineInput $inputString $argumentsReturned | Should Be 'a b c' } - + It 'Should return an empty string when an empty string is passed in' { $inputString = $null $resultString = [String]::Empty $argumentsReturned = Get-ArgumentsFromCommandLineInput -CommandLineInput $inputString $argumentsReturned | Should Be $resultString } - + It 'Should return an empty string when there are no arguments' { $inputString = 'test.txt' $resultString = [String]::Empty @@ -635,7 +641,7 @@ try $argumentsReturned | Should Be $resultString } } - + Describe 'xWindowsProcess\Assert-HashtableDoesNotContainKey' { $mockHashtable = @{ Key1 = 'test key1' @@ -643,23 +649,23 @@ try Key3 = 'test key3' } Mock -CommandName New-InvalidArgumentException -MockWith { Throw $script:exceptionMessage } - + It 'Should not throw an exception if the hashtable does not contain a key' { $mockKey = @('k1', 'k2', 'k3', 'k4', 'k5') { Assert-HashTableDoesNotContainKey -Hashtable $mockHashtable -Key $mockKey } | Should Not Throw } - + It 'Should throw an exception if the hashtable contains a key' { $mockKey = @('k1', 'k2', 'Key3', 'k4', 'k5') { Assert-HashTableDoesNotContainKey -Hashtable $mockHashtable -Key $mockKey } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName New-InvalidArgumentException -Exactly 1 -Scope It } } - + Describe 'xWindowsProcess\Wait-ProcessCount' { - $mockProcessSettings = @{ - Path = 'mockPath' + $mockProcessSettings = @{ + Path = 'mockPath' Arguments = 'mockArguments' } Mock -CommandName Get-ProcessCimInstance -MockWith { return @($script:mockProcess1, $script:mockProcess3) } @@ -668,7 +674,7 @@ try $processCountResult = Wait-ProcessCount -ProcessSettings $mockProcessSettings -ProcessCount 2 $processCountResult | Should Be $true } - + It 'Should return false when not all processes are returned' { $processCountResult = Wait-ProcessCount -ProcessSettings $mockProcessSettings ` -ProcessCount 3 ` @@ -676,48 +682,48 @@ try $processCountResult | Should Be $false } } - + Describe 'xWindowsProcess\Assert-PathArgumentRooted' { Mock -CommandName New-InvalidArgumentException -MockWith { Throw $script:exceptionMessage } It 'Should not throw when path is rooted' { $rootedPath = 'C:\testProcess.exe' - + { Assert-PathArgumentRooted -PathArgumentName 'mock test name' ` -PathArgument $rootedPath } | Should Not Throw } - + It 'Should throw an invalid argument exception when Path is unrooted' { $unrootedPath = 'invalidfile.txt' - - + + { Assert-PathArgumentRooted -PathArgumentName 'mock test name' ` -PathArgument $unrootedPath } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName New-InvalidArgumentException -Exactly 1 -Scope It } } - + Describe 'xWindowsProcess\Assert-PathArgumentValid' { Mock -CommandName New-InvalidArgumentException -MockWith { Throw $script:exceptionMessage } It 'Should not throw when path is valid' { Mock -CommandName Test-Path -MockWith { return $true } - + { Assert-PathArgumentValid -PathArgumentName 'test name' ` -PathArgument 'validPath' } | Should Not Throw } - + It 'Should throw an invalid argument exception when Path is not valid' { Mock -CommandName Test-Path -MockWith { return $false } - + { Assert-PathArgumentValid -PathArgumentName 'test name' ` -PathArgument 'invalidPath' } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName New-InvalidArgumentException -Exactly 1 -Scope It } } - + Describe 'xWindowsProcess\Split-Credential' { Mock -CommandName New-InvalidArgumentException -MockWith { Throw $script:exceptionMessage } @@ -725,57 +731,57 @@ try $testUsername = 'user@domain' $testPassword = ConvertTo-SecureString -String 'dummy' -AsPlainText -Force $testCredential = New-Object -TypeName 'PSCredential' -ArgumentList @($testUsername, $testPassword) - + $splitCredentialResult = Split-Credential -Credential $testCredential - + $splitCredentialResult.Domain | Should Be 'domain' $splitCredentialResult.Username | Should Be 'user' } - + It 'Should return correct domain and username with \ seperator' { $testUsername = 'domain\user' $testPassword = ConvertTo-SecureString -String 'dummy' -AsPlainText -Force $testCredential = New-Object -TypeName 'PSCredential' -ArgumentList @($testUsername, $testPassword) - + $splitCredentialResult = Split-Credential -Credential $testCredential - + $splitCredentialResult.Domain | Should Be 'domain' $splitCredentialResult.Username | Should Be 'user' } - + It 'Should return correct domain and username with a local user' { $testUsername = 'localuser' $testPassword = ConvertTo-SecureString -String 'dummy' -AsPlainText -Force $testCredential = New-Object -TypeName 'PSCredential' -ArgumentList @($testUsername, $testPassword) - + $splitCredentialResult = Split-Credential -Credential $testCredential - + $splitCredentialResult.Domain | Should Be $env:computerName $splitCredentialResult.Username | Should Be 'localuser' } - + It 'Should throw an invalid argument exception when more than one \ in username' { $testUsername = 'user\domain\foo' $testPassword = ConvertTo-SecureString -String 'dummy' -AsPlainText -Force $testCredential = New-Object -TypeName 'PSCredential' -ArgumentList @($testUsername, $testPassword) - + { $splitCredentialResult = Split-Credential -Credential $testCredential } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName New-InvalidArgumentException -Exactly 1 -Scope It } - + It 'Should throw an invalid argument exception when more than one @ in username' { $testUsername = 'user@domain@foo' $testPassword = ConvertTo-SecureString -String 'dummy' -AsPlainText -Force $testCredential = New-Object -TypeName 'PSCredential' -ArgumentList @($testUsername, $testPassword) - + { $splitCredentialResult = Split-Credential -Credential $testCredential } | Should Throw $script:exceptionMessage - + Assert-MockCalled -CommandName New-InvalidArgumentException -Exactly 1 -Scope It } } - } -} + } +} finally { Exit-DscResourceTestEnvironment -TestEnvironment $script:testEnvironment diff --git a/Tests/Unit/ResourceSetHelper.Tests.ps1 b/Tests/Unit/ResourceSetHelper.Tests.ps1 index 0e2faef9a..ac720a94d 100644 --- a/Tests/Unit/ResourceSetHelper.Tests.ps1 +++ b/Tests/Unit/ResourceSetHelper.Tests.ps1 @@ -1,6 +1,12 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () +if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +{ + Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose + return +} + $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' diff --git a/appveyor.yml b/appveyor.yml index 24642527f..8212a27a3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,20 @@ environment: gallery_api: secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv +image: +- Visual Studio 2015 +- Visual Studio 2017 + +configuration: +- Meta +- Unit +- Integration + +matrix: + exclude: + - configuration: Meta + image: Visual Studio 2017 + install: - git clone https://github.com/PowerShell/DscResource.Tests - ps: | @@ -23,20 +37,52 @@ build: false # test configuration # #---------------------------------# -test_script: +for: +- + matrix: + only: + - configuration: Meta + + test_script: + - ps: | + Invoke-AppveyorTestScriptTask ` + -Type 'Default' ` + -ExcludeTag @() + +- + matrix: + only: + - configuration: Integration + environment: + SkipAllCommonTests: True + + test_script: + - ps: | + Invoke-AppveyorTestScriptTask ` + -Type 'Default' ` + -DisableConsistency ` + -ExcludeTag @() + +- + matrix: + only: + - configuration: Unit + environment: + SkipAllCommonTests: True + + test_script: - ps: | Invoke-AppveyorTestScriptTask ` -Type 'Default' ` -CodeCoverage ` -CodeCovIo ` - -DisableConsistency ` -ExcludeTag @() after_test: - - ps: | - Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorAfterTestTask ` - -ResourceModuleName $moduleName +- ps: | + Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" + Invoke-AppveyorAfterTestTask ` + -ResourceModuleName $moduleName #---------------------------------# # deployment configuration # From 16848df602ffc04acc261506557f71311e87bb0c Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 28 Jan 2019 20:47:03 +0100 Subject: [PATCH 02/12] Fix review comment at r1 --- Tests/CommonTestHelper.psm1 | 37 ++++++++++++++++++- .../MSFT_xArchive.EndToEnd.Tests.ps1 | 13 +++---- .../MSFT_xArchive.Integration.Tests.ps1 | 11 ++---- ...FT_xEnvironmentResource.EndToEnd.Tests.ps1 | 11 +++--- ...xEnvironmentResource.Integration.Tests.ps1 | 10 ++--- .../MSFT_xGroupResource.Integration.Tests.ps1 | 11 +++--- .../MSFT_xMsiPackage.EndToEnd.Tests.ps1 | 19 +++++----- .../MSFT_xMsiPackage.Integration.Tests.ps1 | 11 +++--- ...SFT_xPackageResource.Integration.Tests.ps1 | 7 ++-- .../MSFT_xRegistryResource.EndToEnd.Tests.ps1 | 11 +++--- ...FT_xRegistryResource.Integration.Tests.ps1 | 11 +++--- Tests/Integration/MSFT_xRemoteFile.Tests.ps1 | 5 ++- ...MSFT_xScriptResource.Integration.Tests.ps1 | 11 +++--- ...SFT_xServiceResource.Integration.Tests.ps1 | 11 +++--- .../MSFT_xUserResource.Integration.Tests.ps1 | 11 +++--- ...MSFT_xWindowsFeature.Integration.Tests.ps1 | 11 +++--- ...ndowsOptionalFeature.Integration.Tests.ps1 | 5 +++ ...T_xWindowsPackageCab.Integration.Tests.ps1 | 5 +++ ...MSFT_xWindowsProcess.Integration.Tests.ps1 | 11 +++--- .../xGroupSet.Integration.Tests.ps1 | 11 +++--- .../xProcessSet.Integration.Tests.ps1 | 11 +++--- .../xServiceSet.Integration.Tests.ps1 | 11 +++--- .../xWindowsFeatureSet.Integration.Tests.ps1 | 11 +++--- ...wsOptionalFeatureSet.Integration.Tests.ps1 | 11 +++--- Tests/Unit/CommonResourceHelper.Tests.ps1 | 7 +++- Tests/Unit/MSFT_xArchive.Tests.ps1 | 7 +++- Tests/Unit/MSFT_xDSCWebService.Tests.ps1 | 7 +++- .../Unit/MSFT_xEnvironmentResource.Tests.ps1 | 7 +++- Tests/Unit/MSFT_xGroupResource.Tests.ps1 | 11 +++--- Tests/Unit/MSFT_xMsiPackage.Tests.ps1 | 7 +++- Tests/Unit/MSFT_xPackageResource.Tests.ps1 | 6 +-- Tests/Unit/MSFT_xRegistryResource.Tests.ps1 | 11 +++--- Tests/Unit/MSFT_xRemoteFile.Tests.ps1 | 7 +++- Tests/Unit/MSFT_xScriptResource.Tests.ps1 | 11 +++--- Tests/Unit/MSFT_xServiceResource.Tests.ps1 | 11 +++--- Tests/Unit/MSFT_xUserResource.Tests.ps1 | 11 +++--- Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 | 11 +++--- .../MSFT_xWindowsOptionalFeature.Tests.ps1 | 3 +- Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 | 3 +- Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 | 11 +++--- Tests/Unit/ResourceSetHelper.Tests.ps1 | 12 +++--- 41 files changed, 227 insertions(+), 193 deletions(-) diff --git a/Tests/CommonTestHelper.psm1 b/Tests/CommonTestHelper.psm1 index 7defa6e04..098e1ca35 100644 --- a/Tests/CommonTestHelper.psm1 +++ b/Tests/CommonTestHelper.psm1 @@ -789,6 +789,40 @@ function Exit-DscResourceTestEnvironment Restore-TestEnvironment -TestEnvironment $TestEnvironment } +<# + .SYNOPSIS + Exits the specified DSC Resource test environment. + + .PARAMETER TestEnvironment + The test environment to exit. +#> +function Test-SkipCi +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $Name, + + [Parameter(Mandatory = $true)] + [ValidateSet('Unit', 'Integration')] + [System.String] + $Type + ) + + $result = $false + + if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne $Type) + { + Write-Verbose -Message ('Tests for {0} will be skipped unless $env:CONFIGURATION is set to ''{1}''.' -f $Name, $Type) -Verbose + $result = $true + } + + return $result +} + Export-ModuleMember -Function @( 'Test-GetTargetResourceResult', ` 'Wait-ScriptBlockReturnTrue', ` @@ -801,5 +835,6 @@ Export-ModuleMember -Function @( 'Invoke-SetTargetResourceUnitTest', ` 'Invoke-TestTargetResourceUnitTest', ` 'Invoke-ExpectedMocksAreCalledTest', ` - 'Invoke-GenericUnitTest' + 'Invoke-GenericUnitTest', + 'Test-SkipCi' ) diff --git a/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 index bb692e1b9..6042a18c4 100644 --- a/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 @@ -1,19 +1,18 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +# Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment +$testsFolderFilePath = Split-Path $PSScriptRoot -Parent +$commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' +Import-Module -Name $commonTestHelperFilePath + +if ((Test-SkipCi -Name 'MSFT_xArchive.EndToEnd' -Type 'Integration')) { - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose return } Describe 'xArchive End to End Tests' { BeforeAll { - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment - $testsFolderFilePath = Split-Path $PSScriptRoot -Parent - $commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' - Import-Module -Name $commonTestHelperFilePath - $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xArchive' ` diff --git a/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 b/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 index 12ca3ae83..370633489 100644 --- a/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 @@ -1,9 +1,11 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` + -ChildPath 'CommonTestHelper.psm1') + +if ((Test-SkipCi -Name 'MSFT_xArchive' -Type 'Integration')) { - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose return } @@ -15,11 +17,6 @@ if ($PSVersionTable.PSVersion -lt [Version] '5.1') Describe 'xArchive Integration Tests' { BeforeAll { - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment - $testsFolderFilePath = Split-Path $PSScriptRoot -Parent - $commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' - Import-Module -Name $commonTestHelperFilePath - $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xArchive' ` diff --git a/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 index da536d074..3afdb9c6d 100644 --- a/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 @@ -6,17 +6,16 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xEnvironmentResource.EndToEnd' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xEnvironmentResource' ` diff --git a/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 index af37a1bec..a77b803f1 100644 --- a/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 @@ -3,17 +3,17 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xEnvironmentResource' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xEnvironmentResource' ` diff --git a/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 index 36a9d74e9..b8140a1e3 100644 --- a/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 @@ -1,12 +1,6 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] param () -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -15,6 +9,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xGroupResource' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xGroupResource' ` diff --git a/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 index 699aa74f6..a7971673e 100644 --- a/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 @@ -4,22 +4,21 @@ also fail. #> -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +$errorActionPreference = 'Stop' +Set-StrictMode -Version 'Latest' + +# Import CommonTestHelper +$testsFolderFilePath = Split-Path $PSScriptRoot -Parent +$commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' +Import-Module -Name $commonTestHelperFilePath + +if ((Test-SkipCi -Name 'MSFT_xMsiPackage.EndToEnd' -Type 'Integration')) { - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose return } -$errorActionPreference = 'Stop' -Set-StrictMode -Version 'Latest' - Describe 'xMsiPackage End to End Tests' { BeforeAll { - # Import CommonTestHelper - $testsFolderFilePath = Split-Path $PSScriptRoot -Parent - $commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' - Import-Module -Name $commonTestHelperFilePath - $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xMsiPackage' ` diff --git a/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 b/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 index 9e3eb1ca3..f549fe391 100644 --- a/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 @@ -1,16 +1,15 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $script:testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $script:commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xMsiPackage' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xMsiPackage' ` diff --git a/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 index df0384372..a099199ff 100644 --- a/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 @@ -1,11 +1,10 @@ -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +Import-Module "$PSScriptRoot\..\CommonTestHelper.psm1" + +if ((Test-SkipCi -Name 'MSFT_xPackageResource' -Type 'Integration')) { - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose return } -Import-Module "$PSScriptRoot\..\CommonTestHelper.psm1" - $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xPackageResource' ` diff --git a/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 index 28815380e..8bd0a84a4 100644 --- a/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 @@ -5,12 +5,6 @@ If this happens to you, it is fixable, but the fix is difficult and time-consuming. #> -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -19,6 +13,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xRegistryResource.EndToEnd' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xRegistryResource' ` diff --git a/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 index 9e89e235b..290b9f03e 100644 --- a/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 @@ -5,12 +5,6 @@ If this happens to you, it is fixable, but the fix is difficult and time-consuming. #> -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -19,6 +13,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xRegistryResource' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xRegistryResource' ` diff --git a/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 b/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 index 3652624f5..77083683f 100644 --- a/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 +++ b/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 @@ -1,10 +1,11 @@ +Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` + -ChildPath 'CommonTestHelper.psm1') $Global:DSCModuleName = 'xPSDesiredStateConfiguration' # Example xNetworking $Global:DSCResourceName = 'MSFT_xRemoteFile' # Example MSFT_xFirewall -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') +if ((Test-SkipCi -Name 'MSFT_xRemoteFile' -Type 'Integration')) { - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose return } diff --git a/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 index f2eb496ba..d1399d1e2 100644 --- a/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 @@ -1,17 +1,16 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xScriptResource' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xScriptResource' ` diff --git a/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 index 14d02b249..a19020bf9 100644 --- a/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 @@ -7,12 +7,6 @@ also fail. #> -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -21,6 +15,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xServiceResource' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xServiceResource' ` diff --git a/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 index 8b8408d59..3cfaed135 100644 --- a/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 @@ -7,16 +7,15 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force +if ((Test-SkipCi -Name 'MSFT_xUserResource' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xUserResource' ` diff --git a/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 index 0c1c9a25b..30a3974f8 100644 --- a/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 @@ -8,16 +8,15 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force +if ((Test-SkipCi -Name 'MSFT_xWindowsFeature' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xWindowsFeature' ` diff --git a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 index 6166c14d2..bf1f83a5d 100644 --- a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 @@ -7,6 +7,11 @@ if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') +if ((Test-SkipCi -Name 'MSFT_xWindowsOptionalFeature' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xWindowsOptionalFeature' ` diff --git a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 index 941438cff..4234063e7 100644 --- a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 @@ -6,6 +6,11 @@ if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') +if ((Test-SkipCi -Name 'MSFT_xWindowsPackageCab' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xWindowsPackageCab' ` diff --git a/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 index c84dab40f..4ae4faf81 100644 --- a/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 @@ -9,16 +9,15 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force +if ((Test-SkipCi -Name 'MSFT_xWindowsProcess' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xWindowsProcess' ` diff --git a/Tests/Integration/xGroupSet.Integration.Tests.ps1 b/Tests/Integration/xGroupSet.Integration.Tests.ps1 index f960aa9d5..11d57f792 100644 --- a/Tests/Integration/xGroupSet.Integration.Tests.ps1 +++ b/Tests/Integration/xGroupSet.Integration.Tests.ps1 @@ -4,17 +4,16 @@ param () $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'xGroupSet' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'xGroupSet' ` diff --git a/Tests/Integration/xProcessSet.Integration.Tests.ps1 b/Tests/Integration/xProcessSet.Integration.Tests.ps1 index c455cb61d..7722590c4 100644 --- a/Tests/Integration/xProcessSet.Integration.Tests.ps1 +++ b/Tests/Integration/xProcessSet.Integration.Tests.ps1 @@ -1,17 +1,16 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'xProcessSet' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'xProcessSet' ` diff --git a/Tests/Integration/xServiceSet.Integration.Tests.ps1 b/Tests/Integration/xServiceSet.Integration.Tests.ps1 index 654fa1484..886e3c1de 100644 --- a/Tests/Integration/xServiceSet.Integration.Tests.ps1 +++ b/Tests/Integration/xServiceSet.Integration.Tests.ps1 @@ -7,12 +7,6 @@ also fail. #> -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -21,6 +15,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'xServiceSet' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'xServiceSet' ` diff --git a/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 b/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 index db5a59031..a153a842d 100644 --- a/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 +++ b/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 @@ -1,17 +1,16 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'xWindowsFeatureSet' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'xWindowsFeatureSet' ` diff --git a/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 b/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 index 3a02d84d5..0a380aa5e 100644 --- a/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 +++ b/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 @@ -1,17 +1,16 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'xWindowsOptionalFeatureSet' -Type 'Integration')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'xWindowsOptionalFeatureSet' ` diff --git a/Tests/Unit/CommonResourceHelper.Tests.ps1 b/Tests/Unit/CommonResourceHelper.Tests.ps1 index 449b208bf..a3af48786 100644 --- a/Tests/Unit/CommonResourceHelper.Tests.ps1 +++ b/Tests/Unit/CommonResourceHelper.Tests.ps1 @@ -1,9 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +$script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent +$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' +Import-Module -Name $commonTestHelperFilePath + +if ((Test-SkipCi -Name 'CommonResourceHelper' -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } diff --git a/Tests/Unit/MSFT_xArchive.Tests.ps1 b/Tests/Unit/MSFT_xArchive.Tests.ps1 index 9b96aaddc..ee9a69693 100644 --- a/Tests/Unit/MSFT_xArchive.Tests.ps1 +++ b/Tests/Unit/MSFT_xArchive.Tests.ps1 @@ -1,9 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +$script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent +$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' +Import-Module -Name $commonTestHelperFilePath + +if ((Test-SkipCi -Name 'MSFT_xArchive' -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } diff --git a/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 b/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 index 48812c0ee..7971ab705 100644 --- a/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 +++ b/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 @@ -1,9 +1,12 @@ +$script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent +$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' +Import-Module -Name $commonTestHelperFilePath + $script:dscModuleName = 'xPSDesiredStateConfiguration' $script:dscResourceName = 'MSFT_xDSCWebService' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +if ((Test-SkipCi -Name $script:dscResourceName -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } diff --git a/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 b/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 index 638c66008..c51b77987 100644 --- a/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 @@ -1,9 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +$script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent +$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' +Import-Module -Name $commonTestHelperFilePath + +if ((Test-SkipCi -Name 'MSFT_xEnvironmentResource' -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } diff --git a/Tests/Unit/MSFT_xGroupResource.Tests.ps1 b/Tests/Unit/MSFT_xGroupResource.Tests.ps1 index 89cc29357..121d1fca4 100644 --- a/Tests/Unit/MSFT_xGroupResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xGroupResource.Tests.ps1 @@ -1,12 +1,6 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') -{ - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose - return -} - $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -15,6 +9,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xGroupResource' -Type 'Unit')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xGroupResource' ` diff --git a/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 b/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 index 2f562717d..76df41dd0 100644 --- a/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 +++ b/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 @@ -1,9 +1,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +$script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent +$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' +Import-Module -Name $commonTestHelperFilePath + +if ((Test-SkipCi -Name 'MSFT_xMsiPackage' -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } diff --git a/Tests/Unit/MSFT_xPackageResource.Tests.ps1 b/Tests/Unit/MSFT_xPackageResource.Tests.ps1 index bfd9c927d..4c4f52395 100644 --- a/Tests/Unit/MSFT_xPackageResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xPackageResource.Tests.ps1 @@ -1,14 +1,12 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $script:testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' +Import-Module -Name $script:commonTestHelperFilePath -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +if ((Test-SkipCi -Name 'MSFT_xPackageResource' -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } -Import-Module -Name $script:commonTestHelperFilePath - $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xPackageResource' ` diff --git a/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 b/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 index 36726704d..d1dd70303 100644 --- a/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 @@ -1,17 +1,16 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') -{ - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose - return -} - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xRegistryResource' -Type 'Unit')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xRegistryResource' ` diff --git a/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 b/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 index 301ce997a..382cebc4f 100644 --- a/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 +++ b/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 @@ -1,9 +1,12 @@ +$script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent +$script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' +Import-Module -Name $commonTestHelperFilePath + $Global:DSCModuleName = 'xPSDesiredStateConfiguration' $Global:DSCResourceName = 'MSFT_xRemoteFile' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +if ((Test-SkipCi -Name $Global:DSCResourceName -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } diff --git a/Tests/Unit/MSFT_xScriptResource.Tests.ps1 b/Tests/Unit/MSFT_xScriptResource.Tests.ps1 index 4c5afa76f..f78faa2e6 100644 --- a/Tests/Unit/MSFT_xScriptResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xScriptResource.Tests.ps1 @@ -1,17 +1,16 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') -{ - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose - return -} - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xScriptResource' -Type 'Unit')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DSCResourceModuleName 'xPSDesiredStateConfiguration' ` -DSCResourceName 'MSFT_xScriptResource' ` diff --git a/Tests/Unit/MSFT_xServiceResource.Tests.ps1 b/Tests/Unit/MSFT_xServiceResource.Tests.ps1 index 52268bd36..42925431c 100644 --- a/Tests/Unit/MSFT_xServiceResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xServiceResource.Tests.ps1 @@ -2,12 +2,6 @@ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') -{ - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose - return -} - $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' @@ -16,6 +10,11 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath +if ((Test-SkipCi -Name 'MSFT_xServiceResource' -Type 'Unit')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DSCResourceModuleName 'xPSDesiredStateConfiguration' ` -DSCResourceName 'MSFT_xServiceResource' ` diff --git a/Tests/Unit/MSFT_xUserResource.Tests.ps1 b/Tests/Unit/MSFT_xUserResource.Tests.ps1 index 0ad41ff8b..d1f1188aa 100644 --- a/Tests/Unit/MSFT_xUserResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xUserResource.Tests.ps1 @@ -2,16 +2,15 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') -{ - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose - return -} - Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force +if ((Test-SkipCi -Name 'MSFT_xUserResource' -Type 'Unit')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DSCResourceModuleName 'xPSDesiredStateConfiguration' ` -DSCResourceName 'MSFT_xUserResource' ` diff --git a/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 b/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 index 0f5ac60e1..572038e37 100644 --- a/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 @@ -2,16 +2,15 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') -{ - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose - return -} - Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force +if ((Test-SkipCi -Name 'MSFT_xWindowsFeature' -Type 'Unit')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DSCResourceModuleName 'xPSDesiredStateConfiguration' ` -DSCResourceName 'MSFT_xWindowsFeature' ` diff --git a/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 b/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 index 43affe95d..6c37af325 100644 --- a/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 @@ -1,8 +1,7 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +if ((Test-SkipCi -Name 'MSFT_xWindowsOptionalFeature' -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } diff --git a/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 b/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 index 1c5dee622..5eb668968 100644 --- a/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 @@ -1,8 +1,7 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +if ((Test-SkipCi -Name 'MSFT_xWindowsPackageCab' -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } diff --git a/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 b/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 index 403fba3b6..d3f229cd4 100644 --- a/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 @@ -1,18 +1,17 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') -{ - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose - return -} - $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') +if ((Test-SkipCi -Name 'MSFT_xWindowsProcess' -Type 'Unit')) +{ + return +} + $script:testEnvironment = Enter-DscResourceTestEnvironment ` -DscResourceModuleName 'xPSDesiredStateConfiguration' ` -DscResourceName 'MSFT_xWindowsProcess' ` diff --git a/Tests/Unit/ResourceSetHelper.Tests.ps1 b/Tests/Unit/ResourceSetHelper.Tests.ps1 index ac720a94d..f75127dd8 100644 --- a/Tests/Unit/ResourceSetHelper.Tests.ps1 +++ b/Tests/Unit/ResourceSetHelper.Tests.ps1 @@ -1,15 +1,17 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Unit') +$errorActionPreference = 'Stop' +Set-StrictMode -Version 'Latest' + +Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` + -ChildPath 'CommonTestHelper.psm1') + +if ((Test-SkipCi -Name 'MSFT_xWindowsProcess' -Type 'Unit')) { - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Unit''.' -Verbose return } -$errorActionPreference = 'Stop' -Set-StrictMode -Version 'Latest' - $script:testsFolderFilePath = Split-Path -Path $PSScriptRoot -Parent $script:moduleRootFilePath = Split-Path -Path $script:testsFolderFilePath -Parent $script:dscResourcesFolderFilePath = Join-Path -Path $script:moduleRootFilePath -ChildPath 'DscResources' From 738b6ed38b62e6aebd341ea9533f7e295c5cd2c2 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Mon, 28 Jan 2019 20:49:11 +0100 Subject: [PATCH 03/12] Remove code from non-testfile --- Tests/Integration/MSFT_xDSCWebService.xxx.ps1 | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Tests/Integration/MSFT_xDSCWebService.xxx.ps1 b/Tests/Integration/MSFT_xDSCWebService.xxx.ps1 index fa2baf9b0..64be95474 100644 --- a/Tests/Integration/MSFT_xDSCWebService.xxx.ps1 +++ b/Tests/Integration/MSFT_xDSCWebService.xxx.ps1 @@ -6,12 +6,6 @@ # Run as an elevated administrator ###################################################################################### -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Unit test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - # Create a unique name that we use for our temp files and folders [System.String] $tempFolderName = 'xDSCWebServiceTests_' + (Get-Date).ToString("yyyyMMdd_HHmmss") From 5880437bb549bfb30415b8154617de109e5a6667 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 29 Jan 2019 10:10:05 +0100 Subject: [PATCH 04/12] FIx review comment at r3 --- Tests/CommonTestHelper.psm1 | 19 +++++++++++++------ .../MSFT_xArchive.EndToEnd.Tests.ps1 | 2 +- .../MSFT_xArchive.Integration.Tests.ps1 | 2 +- ...FT_xEnvironmentResource.EndToEnd.Tests.ps1 | 2 +- ...xEnvironmentResource.Integration.Tests.ps1 | 2 +- .../MSFT_xGroupResource.Integration.Tests.ps1 | 2 +- .../MSFT_xMsiPackage.EndToEnd.Tests.ps1 | 2 +- .../MSFT_xMsiPackage.Integration.Tests.ps1 | 2 +- ...SFT_xPackageResource.Integration.Tests.ps1 | 2 +- .../MSFT_xRegistryResource.EndToEnd.Tests.ps1 | 2 +- ...FT_xRegistryResource.Integration.Tests.ps1 | 2 +- Tests/Integration/MSFT_xRemoteFile.Tests.ps1 | 2 +- ...MSFT_xScriptResource.Integration.Tests.ps1 | 2 +- ...SFT_xServiceResource.Integration.Tests.ps1 | 2 +- .../MSFT_xUserResource.Integration.Tests.ps1 | 2 +- ...MSFT_xWindowsFeature.Integration.Tests.ps1 | 2 +- ...ndowsOptionalFeature.Integration.Tests.ps1 | 2 +- ...T_xWindowsPackageCab.Integration.Tests.ps1 | 2 +- ...MSFT_xWindowsProcess.Integration.Tests.ps1 | 2 +- .../xGroupSet.Integration.Tests.ps1 | 2 +- .../xProcessSet.Integration.Tests.ps1 | 2 +- .../xServiceSet.Integration.Tests.ps1 | 2 +- .../xWindowsFeatureSet.Integration.Tests.ps1 | 2 +- ...wsOptionalFeatureSet.Integration.Tests.ps1 | 2 +- Tests/Unit/CommonResourceHelper.Tests.ps1 | 2 +- Tests/Unit/MSFT_xArchive.Tests.ps1 | 2 +- .../Unit/MSFT_xEnvironmentResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xGroupResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xMsiPackage.Tests.ps1 | 2 +- Tests/Unit/MSFT_xPackageResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xRegistryResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xScriptResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xServiceResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xUserResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 | 2 +- .../MSFT_xWindowsOptionalFeature.Tests.ps1 | 2 +- Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 | 2 +- Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 | 2 +- Tests/Unit/ResourceSetHelper.Tests.ps1 | 2 +- 39 files changed, 51 insertions(+), 44 deletions(-) diff --git a/Tests/CommonTestHelper.psm1 b/Tests/CommonTestHelper.psm1 index 098e1ca35..ccbab8fd3 100644 --- a/Tests/CommonTestHelper.psm1 +++ b/Tests/CommonTestHelper.psm1 @@ -791,20 +791,27 @@ function Exit-DscResourceTestEnvironment <# .SYNOPSIS - Exits the specified DSC Resource test environment. + Returns $true if the the environment variable APPVEYOR is set to $true, + and the environment variable CONFIGURATION is set to the value passed + in the parameter Type. - .PARAMETER TestEnvironment - The test environment to exit. + .PARAMETER Name + Name of the test script that is called. Defaults to the name of the + calling script. + + .PARAMETER Type + Type of tests in the test file. Can be set to Unit or Integration. #> function Test-SkipCi { + [OutputType([System.Boolean])] [CmdletBinding()] param ( - [Parameter(Mandatory = $true)] + [Parameter()] [ValidateNotNullOrEmpty()] [System.String] - $Name, + $Name = $MyInvocation.PSCommandPath.Split('\')[-1], [Parameter(Mandatory = $true)] [ValidateSet('Unit', 'Integration')] @@ -816,7 +823,7 @@ function Test-SkipCi if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne $Type) { - Write-Verbose -Message ('Tests for {0} will be skipped unless $env:CONFIGURATION is set to ''{1}''.' -f $Name, $Type) -Verbose + Write-Verbose -Message ('{1} tests for {0} will be skipped unless $env:CONFIGURATION is set to ''{1}''.' -f $Name, $Type) -Verbose $result = $true } diff --git a/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 index 6042a18c4..6e523eb3b 100644 --- a/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 @@ -6,7 +6,7 @@ $testsFolderFilePath = Split-Path $PSScriptRoot -Parent $commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xArchive.EndToEnd' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 b/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 index 370633489..f924540d0 100644 --- a/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 @@ -4,7 +4,7 @@ Set-StrictMode -Version 'Latest' Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Name 'MSFT_xArchive' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 index 3afdb9c6d..34aa80d05 100644 --- a/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 @@ -11,7 +11,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xEnvironmentResource.EndToEnd' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 index a77b803f1..5f18e45c4 100644 --- a/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 @@ -9,7 +9,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xEnvironmentResource' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 index b8140a1e3..8906e1149 100644 --- a/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 @@ -9,7 +9,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xGroupResource' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 index a7971673e..55e784fe5 100644 --- a/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 @@ -12,7 +12,7 @@ $testsFolderFilePath = Split-Path $PSScriptRoot -Parent $commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xMsiPackage.EndToEnd' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 b/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 index f549fe391..fe296b37a 100644 --- a/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $script:testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $script:commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xMsiPackage' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 index a099199ff..f7ede65b9 100644 --- a/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module "$PSScriptRoot\..\CommonTestHelper.psm1" -if ((Test-SkipCi -Name 'MSFT_xPackageResource' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 index 8bd0a84a4..1c372395a 100644 --- a/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 @@ -13,7 +13,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xRegistryResource.EndToEnd' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 index 290b9f03e..67477d63f 100644 --- a/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 @@ -13,7 +13,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xRegistryResource' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 b/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 index 77083683f..b7c583813 100644 --- a/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 +++ b/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 @@ -4,7 +4,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` $Global:DSCModuleName = 'xPSDesiredStateConfiguration' # Example xNetworking $Global:DSCResourceName = 'MSFT_xRemoteFile' # Example MSFT_xFirewall -if ((Test-SkipCi -Name 'MSFT_xRemoteFile' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 index d1399d1e2..c777cee14 100644 --- a/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xScriptResource' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 index a19020bf9..d6707807d 100644 --- a/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 @@ -15,7 +15,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xServiceResource' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 index 3cfaed135..1096433a1 100644 --- a/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 @@ -11,7 +11,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Name 'MSFT_xUserResource' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 index 30a3974f8..18d9ab218 100644 --- a/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 @@ -12,7 +12,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Name 'MSFT_xWindowsFeature' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 index bf1f83a5d..6a74a80d0 100644 --- a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 @@ -7,7 +7,7 @@ if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Name 'MSFT_xWindowsOptionalFeature' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 index 4234063e7..8d9ea6a1f 100644 --- a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 @@ -6,7 +6,7 @@ if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Name 'MSFT_xWindowsPackageCab' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 index 4ae4faf81..f14e83627 100644 --- a/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 @@ -13,7 +13,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Name 'MSFT_xWindowsProcess' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/xGroupSet.Integration.Tests.ps1 b/Tests/Integration/xGroupSet.Integration.Tests.ps1 index 11d57f792..525870360 100644 --- a/Tests/Integration/xGroupSet.Integration.Tests.ps1 +++ b/Tests/Integration/xGroupSet.Integration.Tests.ps1 @@ -9,7 +9,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'xGroupSet' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/xProcessSet.Integration.Tests.ps1 b/Tests/Integration/xProcessSet.Integration.Tests.ps1 index 7722590c4..2c37e909d 100644 --- a/Tests/Integration/xProcessSet.Integration.Tests.ps1 +++ b/Tests/Integration/xProcessSet.Integration.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'xProcessSet' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/xServiceSet.Integration.Tests.ps1 b/Tests/Integration/xServiceSet.Integration.Tests.ps1 index 886e3c1de..f8be98d01 100644 --- a/Tests/Integration/xServiceSet.Integration.Tests.ps1 +++ b/Tests/Integration/xServiceSet.Integration.Tests.ps1 @@ -15,7 +15,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'xServiceSet' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 b/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 index a153a842d..1ba56497c 100644 --- a/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 +++ b/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'xWindowsFeatureSet' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 b/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 index 0a380aa5e..2307899a3 100644 --- a/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 +++ b/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'xWindowsOptionalFeatureSet' -Type 'Integration')) +if ((Test-SkipCi -Type 'Integration')) { return } diff --git a/Tests/Unit/CommonResourceHelper.Tests.ps1 b/Tests/Unit/CommonResourceHelper.Tests.ps1 index a3af48786..9cf599133 100644 --- a/Tests/Unit/CommonResourceHelper.Tests.ps1 +++ b/Tests/Unit/CommonResourceHelper.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'CommonResourceHelper' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xArchive.Tests.ps1 b/Tests/Unit/MSFT_xArchive.Tests.ps1 index ee9a69693..731cc480b 100644 --- a/Tests/Unit/MSFT_xArchive.Tests.ps1 +++ b/Tests/Unit/MSFT_xArchive.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xArchive' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 b/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 index c51b77987..2ec6c442b 100644 --- a/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xEnvironmentResource' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xGroupResource.Tests.ps1 b/Tests/Unit/MSFT_xGroupResource.Tests.ps1 index 121d1fca4..12a95d7cf 100644 --- a/Tests/Unit/MSFT_xGroupResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xGroupResource.Tests.ps1 @@ -9,7 +9,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xGroupResource' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 b/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 index 76df41dd0..85189373b 100644 --- a/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 +++ b/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xMsiPackage' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xPackageResource.Tests.ps1 b/Tests/Unit/MSFT_xPackageResource.Tests.ps1 index 4c4f52395..b4611b7ad 100644 --- a/Tests/Unit/MSFT_xPackageResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xPackageResource.Tests.ps1 @@ -2,7 +2,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $script:testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $script:commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xPackageResource' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 b/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 index d1dd70303..b277160ad 100644 --- a/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xRegistryResource' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xScriptResource.Tests.ps1 b/Tests/Unit/MSFT_xScriptResource.Tests.ps1 index f78faa2e6..4861bd31d 100644 --- a/Tests/Unit/MSFT_xScriptResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xScriptResource.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xScriptResource' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xServiceResource.Tests.ps1 b/Tests/Unit/MSFT_xServiceResource.Tests.ps1 index 42925431c..79449da05 100644 --- a/Tests/Unit/MSFT_xServiceResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xServiceResource.Tests.ps1 @@ -10,7 +10,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Name 'MSFT_xServiceResource' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xUserResource.Tests.ps1 b/Tests/Unit/MSFT_xUserResource.Tests.ps1 index d1f1188aa..c1bfd548a 100644 --- a/Tests/Unit/MSFT_xUserResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xUserResource.Tests.ps1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Name 'MSFT_xUserResource' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 b/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 index 572038e37..50f520ed6 100644 --- a/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Name 'MSFT_xWindowsFeature' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 b/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 index 6c37af325..6dbb73f0f 100644 --- a/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Name 'MSFT_xWindowsOptionalFeature' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 b/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 index 5eb668968..3f2480531 100644 --- a/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Name 'MSFT_xWindowsPackageCab' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 b/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 index d3f229cd4..104572367 100644 --- a/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 @@ -7,7 +7,7 @@ Set-StrictMode -Version 'Latest' Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Name 'MSFT_xWindowsProcess' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } diff --git a/Tests/Unit/ResourceSetHelper.Tests.ps1 b/Tests/Unit/ResourceSetHelper.Tests.ps1 index f75127dd8..4ab8f2481 100644 --- a/Tests/Unit/ResourceSetHelper.Tests.ps1 +++ b/Tests/Unit/ResourceSetHelper.Tests.ps1 @@ -7,7 +7,7 @@ Set-StrictMode -Version 'Latest' Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Name 'MSFT_xWindowsProcess' -Type 'Unit')) +if ((Test-SkipCi -Type 'Unit')) { return } From 2f8cdee42c98e881c4642e4d9b56a97cac0e7c47 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 30 Jan 2019 07:43:34 +0100 Subject: [PATCH 05/12] Fix review comments at r4 --- Tests/CommonTestHelper.psm1 | 2 +- .../MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 | 7 ------- .../MSFT_xWindowsPackageCab.Integration.Tests.ps1 | 6 ------ 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/Tests/CommonTestHelper.psm1 b/Tests/CommonTestHelper.psm1 index ccbab8fd3..e84d47ad7 100644 --- a/Tests/CommonTestHelper.psm1 +++ b/Tests/CommonTestHelper.psm1 @@ -823,7 +823,7 @@ function Test-SkipCi if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne $Type) { - Write-Verbose -Message ('{1} tests for {0} will be skipped unless $env:CONFIGURATION is set to ''{1}''.' -f $Name, $Type) -Verbose + Write-Verbose -Message ('{1} tests in {0} will be skipped unless $env:CONFIGURATION is set to ''{1}''.' -f $Name, $Type) -Verbose $result = $true } diff --git a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 index 6a74a80d0..2deae9980 100644 --- a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 @@ -1,10 +1,3 @@ -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - - Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') if ((Test-SkipCi -Type 'Integration')) diff --git a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 index 8d9ea6a1f..6f5dbe44c 100644 --- a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 @@ -1,9 +1,3 @@ -if ($env:APPVEYOR -eq $true -and $env:CONFIGURATION -ne 'Integration') -{ - Write-Verbose -Message 'Integration test for will be skipped unless $env:CONFIGURATION is set to ''Integration''.' -Verbose - return -} - Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') if ((Test-SkipCi -Type 'Integration')) From d00db0edda84a5cc4737aa075e5c222f997f1f5d Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Wed, 30 Jan 2019 16:53:30 +0100 Subject: [PATCH 06/12] Run Codecov only on one image --- appveyor.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 8212a27a3..ac53e257c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,15 +6,24 @@ environment: gallery_api: secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv +# The images that will be used when building the job matrix. image: - Visual Studio 2015 - Visual Studio 2017 +# The configuration that will be used when building the job matrix. +# Meta = Test Framework Common Test +# Unit = Module Unit Tests. +# Integration = Module Integration Tests. configuration: - Meta - Unit - Integration +# The jobs that will excluded based on the combination of configuration name +# and image name. +# This will make sure the meta tests (common tests) are only run on one of the +# images. matrix: exclude: - configuration: Meta @@ -37,8 +46,19 @@ build: false # test configuration # #---------------------------------# +# This will build the job matrix (exception is what is excluded from the matrix +# above). The jobs will be order by the order of key 'configuration:' and then +# by the key 'images:'. +# +# Job 1: Run meta test (common tests) on image Visual Studio 2015. +# Job 2: Run unit tests on image Visual Studio 2015, including Codecov report. +# Job 3: Run integration tests on image Visual Studio 2015. +# Job 4: Run unit tests on image Visual Studio 2017, without Codecov report. +# Job 5: Run integration tests on image Visual Studio 2017. + for: - + # Job 1. matrix: only: - configuration: Meta @@ -50,6 +70,7 @@ for: -ExcludeTag @() - + # Job 3 and job 4. matrix: only: - configuration: Integration @@ -64,9 +85,11 @@ for: -ExcludeTag @() - + # Job 2. matrix: only: - configuration: Unit + image: Visual Studio 2015 environment: SkipAllCommonTests: True @@ -78,6 +101,23 @@ for: -CodeCovIo ` -ExcludeTag @() +- + # Job 5. + matrix: + only: + - configuration: Unit + image: Visual Studio 2017 + environment: + SkipAllCommonTests: True + + test_script: + - ps: | + Invoke-AppveyorTestScriptTask ` + -Type 'Default' ` + -CodeCoverage ` + -ExcludeTag @() + +# Runs for all jobs. after_test: - ps: | Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" @@ -88,6 +128,7 @@ after_test: # deployment configuration # #---------------------------------# +# Runs for all jobs, but only when test step is successful. deploy_script: - ps: | Invoke-AppVeyorDeployTask From 3434d3adb4daf952e07e93f2650fad5ac6b1fe5d Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Fri, 1 Feb 2019 16:36:24 +0100 Subject: [PATCH 07/12] Switch to running tests for latest OS first (including meta tests) --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ac53e257c..3413f2293 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,8 +8,8 @@ environment: # The images that will be used when building the job matrix. image: -- Visual Studio 2015 - Visual Studio 2017 +- Visual Studio 2015 # The configuration that will be used when building the job matrix. # Meta = Test Framework Common Test @@ -27,7 +27,7 @@ configuration: matrix: exclude: - configuration: Meta - image: Visual Studio 2017 + image: Visual Studio 2015 install: - git clone https://github.com/PowerShell/DscResource.Tests From 04e2ca3b40dbfdb518f575bbbda2fa1d42544122 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 2 Feb 2019 11:16:50 +0100 Subject: [PATCH 08/12] Fix review comments at r7 --- README.md | 6 +++--- Tests/CommonTestHelper.psm1 | 4 ++-- .../MSFT_xArchive.EndToEnd.Tests.ps1 | 2 +- .../MSFT_xArchive.Integration.Tests.ps1 | 2 +- ...FT_xEnvironmentResource.EndToEnd.Tests.ps1 | 2 +- ...xEnvironmentResource.Integration.Tests.ps1 | 3 +-- .../MSFT_xGroupResource.Integration.Tests.ps1 | 2 +- .../MSFT_xMsiPackage.EndToEnd.Tests.ps1 | 2 +- .../MSFT_xMsiPackage.Integration.Tests.ps1 | 2 +- ...SFT_xPackageResource.Integration.Tests.ps1 | 2 +- .../MSFT_xRegistryResource.EndToEnd.Tests.ps1 | 2 +- ...FT_xRegistryResource.Integration.Tests.ps1 | 2 +- Tests/Integration/MSFT_xRemoteFile.Tests.ps1 | 16 ++++++++-------- ...MSFT_xScriptResource.Integration.Tests.ps1 | 2 +- ...SFT_xServiceResource.Integration.Tests.ps1 | 2 +- .../MSFT_xUserResource.Integration.Tests.ps1 | 2 +- ...MSFT_xWindowsFeature.Integration.Tests.ps1 | 2 +- ...ndowsOptionalFeature.Integration.Tests.ps1 | 2 +- ...T_xWindowsPackageCab.Integration.Tests.ps1 | 2 +- ...MSFT_xWindowsProcess.Integration.Tests.ps1 | 2 +- .../xGroupSet.Integration.Tests.ps1 | 2 +- .../xProcessSet.Integration.Tests.ps1 | 2 +- .../xServiceSet.Integration.Tests.ps1 | 2 +- .../xWindowsFeatureSet.Integration.Tests.ps1 | 2 +- ...wsOptionalFeatureSet.Integration.Tests.ps1 | 2 +- Tests/Unit/CommonResourceHelper.Tests.ps1 | 2 +- Tests/Unit/MSFT_xArchive.Tests.ps1 | 2 +- Tests/Unit/MSFT_xDSCWebService.Tests.ps1 | 2 +- .../Unit/MSFT_xEnvironmentResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xGroupResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xMsiPackage.Tests.ps1 | 2 +- Tests/Unit/MSFT_xPackageResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xRegistryResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xRemoteFile.Tests.ps1 | 2 +- Tests/Unit/MSFT_xScriptResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xServiceResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xUserResource.Tests.ps1 | 2 +- Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 | 2 +- .../MSFT_xWindowsOptionalFeature.Tests.ps1 | 2 +- Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 | 2 +- Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 | 2 +- Tests/Unit/ResourceSetHelper.Tests.ps1 | 2 +- appveyor.yml | 19 ++++++++++--------- 43 files changed, 62 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 5847d4bb8..04ba8b665 100644 --- a/README.md +++ b/README.md @@ -716,9 +716,9 @@ Publishes a 'FileInfo' object(s) to the pullserver configuration repository. It * Changes to xPSDesiredStateConfiguration * In AppVeyor CI the tests are split into three separate jobs, and also - running tests on two different build worker images (Windows Server - 2012R2 and Windows Server 2016). The common tests are run on only - one of the build worker images (Windows Server 2012R2). Helps with + run tests on two different build worker images (Windows Server 2012R2 + and Windows Server 2016). The common tests are only run on the + Windows Server 2016 build worker image. Helps with [issue #477](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/477). * xWindowsOptionalFeature * Suppress useless verbose output from `Import-Module` cmdlet. ([issue 453](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/453)) diff --git a/Tests/CommonTestHelper.psm1 b/Tests/CommonTestHelper.psm1 index e84d47ad7..c34dc36c2 100644 --- a/Tests/CommonTestHelper.psm1 +++ b/Tests/CommonTestHelper.psm1 @@ -802,7 +802,7 @@ function Exit-DscResourceTestEnvironment .PARAMETER Type Type of tests in the test file. Can be set to Unit or Integration. #> -function Test-SkipCi +function Test-SkipContinuousIntegrationTask { [OutputType([System.Boolean])] [CmdletBinding()] @@ -843,5 +843,5 @@ Export-ModuleMember -Function @( 'Invoke-TestTargetResourceUnitTest', ` 'Invoke-ExpectedMocksAreCalledTest', ` 'Invoke-GenericUnitTest', - 'Test-SkipCi' + 'Test-SkipContinuousIntegrationTask' ) diff --git a/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 index 6e523eb3b..b181f5e36 100644 --- a/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xArchive.EndToEnd.Tests.ps1 @@ -6,7 +6,7 @@ $testsFolderFilePath = Split-Path $PSScriptRoot -Parent $commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 b/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 index f924540d0..d423c2d8d 100644 --- a/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xArchive.Integration.Tests.ps1 @@ -4,7 +4,7 @@ Set-StrictMode -Version 'Latest' Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 index 34aa80d05..e5364d3b8 100644 --- a/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xEnvironmentResource.EndToEnd.Tests.ps1 @@ -11,7 +11,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 index 5f18e45c4..63a80b0ad 100644 --- a/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xEnvironmentResource.Integration.Tests.ps1 @@ -3,13 +3,12 @@ $errorActionPreference = 'Stop' Set-StrictMode -Version 'Latest' - # Import CommonTestHelper for Enter-DscResourceTestEnvironment, Exit-DscResourceTestEnvironment $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 index 8906e1149..48356b4a4 100644 --- a/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xGroupResource.Integration.Tests.ps1 @@ -9,7 +9,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 index 55e784fe5..6bc425b33 100644 --- a/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xMsiPackage.EndToEnd.Tests.ps1 @@ -12,7 +12,7 @@ $testsFolderFilePath = Split-Path $PSScriptRoot -Parent $commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 b/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 index fe296b37a..0eb2c760d 100644 --- a/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xMsiPackage.Integration.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $script:testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $script:commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 index f7ede65b9..9e2eb3449 100644 --- a/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xPackageResource.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module "$PSScriptRoot\..\CommonTestHelper.psm1" -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 b/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 index 1c372395a..49fafe529 100644 --- a/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 +++ b/Tests/Integration/MSFT_xRegistryResource.EndToEnd.Tests.ps1 @@ -13,7 +13,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 index 67477d63f..022dc581a 100644 --- a/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1 @@ -13,7 +13,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 b/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 index b7c583813..357758ea8 100644 --- a/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 +++ b/Tests/Integration/MSFT_xRemoteFile.Tests.ps1 @@ -1,10 +1,10 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') -$Global:DSCModuleName = 'xPSDesiredStateConfiguration' # Example xNetworking -$Global:DSCResourceName = 'MSFT_xRemoteFile' # Example MSFT_xFirewall +$script:DSCModuleName = 'xPSDesiredStateConfiguration' # Example xNetworking +$script:DSCResourceName = 'MSFT_xRemoteFile' # Example MSFT_xFirewall -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } @@ -20,8 +20,8 @@ if ( (-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $Global:DSCModuleName ` - -DSCResourceName $Global:DSCResourceName ` + -DSCModuleName $script:DSCModuleName ` + -DSCResourceName $script:DSCResourceName ` -TestType Integration #endregion @@ -29,17 +29,17 @@ $TestEnvironment = Initialize-TestEnvironment ` try { #region Integration Tests - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($Global:DSCResourceName).config.ps1" + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" . $ConfigFile # Make sure the file to download doesn't exist Remove-Item -Path $TestDestinationPath -Force -ErrorAction SilentlyContinue - Describe "$($Global:DSCResourceName)_Integration" { + Describe "$($script:DSCResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile without throwing' { { - Invoke-Expression -Command "$($Global:DSCResourceName)_Config -OutputPath `$TestDrive" + Invoke-Expression -Command "$($script:DSCResourceName)_Config -OutputPath `$TestDrive" Start-DscConfiguration -Path $TestDrive ` -ComputerName localhost -Wait -Verbose -Force } | Should not throw diff --git a/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 index c777cee14..123d797bb 100644 --- a/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xScriptResource.Integration.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 index d6707807d..d089870b2 100644 --- a/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xServiceResource.Integration.Tests.ps1 @@ -15,7 +15,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 b/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 index 1096433a1..7b3f9e75a 100644 --- a/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xUserResource.Integration.Tests.ps1 @@ -11,7 +11,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 index 18d9ab218..eb87ab1a6 100644 --- a/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsFeature.Integration.Tests.ps1 @@ -12,7 +12,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 index 2deae9980..22ce0b45e 100644 --- a/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsOptionalFeature.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 index 6f5dbe44c..a393055ae 100644 --- a/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsPackageCab.Integration.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 index f14e83627..ffe5f8a25 100644 --- a/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWindowsProcess.Integration.Tests.ps1 @@ -13,7 +13,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/xGroupSet.Integration.Tests.ps1 b/Tests/Integration/xGroupSet.Integration.Tests.ps1 index 525870360..da906896d 100644 --- a/Tests/Integration/xGroupSet.Integration.Tests.ps1 +++ b/Tests/Integration/xGroupSet.Integration.Tests.ps1 @@ -9,7 +9,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/xProcessSet.Integration.Tests.ps1 b/Tests/Integration/xProcessSet.Integration.Tests.ps1 index 2c37e909d..962fd5f19 100644 --- a/Tests/Integration/xProcessSet.Integration.Tests.ps1 +++ b/Tests/Integration/xProcessSet.Integration.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/xServiceSet.Integration.Tests.ps1 b/Tests/Integration/xServiceSet.Integration.Tests.ps1 index f8be98d01..2ff9b0968 100644 --- a/Tests/Integration/xServiceSet.Integration.Tests.ps1 +++ b/Tests/Integration/xServiceSet.Integration.Tests.ps1 @@ -15,7 +15,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 b/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 index 1ba56497c..781f3fa73 100644 --- a/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 +++ b/Tests/Integration/xWindowsFeatureSet.Integration.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 b/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 index 2307899a3..4814dcc2a 100644 --- a/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 +++ b/Tests/Integration/xWindowsOptionalFeatureSet.Integration.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Integration')) +if (Test-SkipContinuousIntegrationTask -Type 'Integration') { return } diff --git a/Tests/Unit/CommonResourceHelper.Tests.ps1 b/Tests/Unit/CommonResourceHelper.Tests.ps1 index 9cf599133..3378d3a1b 100644 --- a/Tests/Unit/CommonResourceHelper.Tests.ps1 +++ b/Tests/Unit/CommonResourceHelper.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xArchive.Tests.ps1 b/Tests/Unit/MSFT_xArchive.Tests.ps1 index 731cc480b..0e4dc6eb2 100644 --- a/Tests/Unit/MSFT_xArchive.Tests.ps1 +++ b/Tests/Unit/MSFT_xArchive.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 b/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 index 7971ab705..e9721a287 100644 --- a/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 +++ b/Tests/Unit/MSFT_xDSCWebService.Tests.ps1 @@ -5,7 +5,7 @@ Import-Module -Name $commonTestHelperFilePath $script:dscModuleName = 'xPSDesiredStateConfiguration' $script:dscResourceName = 'MSFT_xDSCWebService' -if ((Test-SkipCi -Name $script:dscResourceName -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 b/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 index 2ec6c442b..1765b3afb 100644 --- a/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xEnvironmentResource.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xGroupResource.Tests.ps1 b/Tests/Unit/MSFT_xGroupResource.Tests.ps1 index 12a95d7cf..2f5d62ffb 100644 --- a/Tests/Unit/MSFT_xGroupResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xGroupResource.Tests.ps1 @@ -9,7 +9,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 b/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 index 85189373b..d09d858d3 100644 --- a/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 +++ b/Tests/Unit/MSFT_xMsiPackage.Tests.ps1 @@ -5,7 +5,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xPackageResource.Tests.ps1 b/Tests/Unit/MSFT_xPackageResource.Tests.ps1 index b4611b7ad..55c4ed60e 100644 --- a/Tests/Unit/MSFT_xPackageResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xPackageResource.Tests.ps1 @@ -2,7 +2,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $script:testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $script:commonTestHelperFilePath -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 b/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 index b277160ad..26a8914b9 100644 --- a/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xRegistryResource.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 b/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 index 382cebc4f..86c0e75e4 100644 --- a/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 +++ b/Tests/Unit/MSFT_xRemoteFile.Tests.ps1 @@ -5,7 +5,7 @@ Import-Module -Name $commonTestHelperFilePath $Global:DSCModuleName = 'xPSDesiredStateConfiguration' $Global:DSCResourceName = 'MSFT_xRemoteFile' -if ((Test-SkipCi -Name $Global:DSCResourceName -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xScriptResource.Tests.ps1 b/Tests/Unit/MSFT_xScriptResource.Tests.ps1 index 4861bd31d..dfd2f275e 100644 --- a/Tests/Unit/MSFT_xScriptResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xScriptResource.Tests.ps1 @@ -6,7 +6,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xServiceResource.Tests.ps1 b/Tests/Unit/MSFT_xServiceResource.Tests.ps1 index 79449da05..f61793731 100644 --- a/Tests/Unit/MSFT_xServiceResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xServiceResource.Tests.ps1 @@ -10,7 +10,7 @@ $script:testsFolderFilePath = Split-Path $PSScriptRoot -Parent $script:commonTestHelperFilePath = Join-Path -Path $testsFolderFilePath -ChildPath 'CommonTestHelper.psm1' Import-Module -Name $commonTestHelperFilePath -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xUserResource.Tests.ps1 b/Tests/Unit/MSFT_xUserResource.Tests.ps1 index c1bfd548a..01dee4f3b 100644 --- a/Tests/Unit/MSFT_xUserResource.Tests.ps1 +++ b/Tests/Unit/MSFT_xUserResource.Tests.ps1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 b/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 index 50f520ed6..80fbcce05 100644 --- a/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsFeature.Tests.ps1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') ` -Force -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 b/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 index 6dbb73f0f..e811361e9 100644 --- a/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsOptionalFeature.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 b/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 index 3f2480531..06109baa6 100644 --- a/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsPackageCab.Tests.ps1 @@ -1,6 +1,6 @@ Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 b/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 index 104572367..cdc6f1e70 100644 --- a/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 +++ b/Tests/Unit/MSFT_xWindowsProcess.Tests.ps1 @@ -7,7 +7,7 @@ Set-StrictMode -Version 'Latest' Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/Tests/Unit/ResourceSetHelper.Tests.ps1 b/Tests/Unit/ResourceSetHelper.Tests.ps1 index 4ab8f2481..51851644c 100644 --- a/Tests/Unit/ResourceSetHelper.Tests.ps1 +++ b/Tests/Unit/ResourceSetHelper.Tests.ps1 @@ -7,7 +7,7 @@ Set-StrictMode -Version 'Latest' Import-Module -Name (Join-Path -Path (Split-Path $PSScriptRoot -Parent) ` -ChildPath 'CommonTestHelper.psm1') -if ((Test-SkipCi -Type 'Unit')) +if (Test-SkipContinuousIntegrationTask -Type 'Unit') { return } diff --git a/appveyor.yml b/appveyor.yml index 3413f2293..fc4b9de5c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,6 +25,7 @@ configuration: # This will make sure the meta tests (common tests) are only run on one of the # images. matrix: + fast_finish: true exclude: - configuration: Meta image: Visual Studio 2015 @@ -117,18 +118,18 @@ for: -CodeCoverage ` -ExcludeTag @() + #---------------------------------# + # deployment configuration # + #---------------------------------# + + # Runs only in job 5, and only when all are successful. + deploy_script: + - ps: | + Invoke-AppVeyorDeployTask + # Runs for all jobs. after_test: - ps: | Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" Invoke-AppveyorAfterTestTask ` -ResourceModuleName $moduleName - -#---------------------------------# -# deployment configuration # -#---------------------------------# - -# Runs for all jobs, but only when test step is successful. -deploy_script: - - ps: | - Invoke-AppVeyorDeployTask From a1e6ff124fdccbcdae6b88574444c7a613ce10a3 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 2 Feb 2019 13:20:49 +0100 Subject: [PATCH 09/12] Update deploy step in appveyor.yml --- appveyor.yml | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index fc4b9de5c..a91f51c18 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,8 @@ version: 6.0.{build}.0 environment: gallery_api: secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv + # The job where deploy step should run (normally the last job) + DeployInJobNumber: 5 # The images that will be used when building the job matrix. image: @@ -51,11 +53,11 @@ build: false # above). The jobs will be order by the order of key 'configuration:' and then # by the key 'images:'. # -# Job 1: Run meta test (common tests) on image Visual Studio 2015. -# Job 2: Run unit tests on image Visual Studio 2015, including Codecov report. -# Job 3: Run integration tests on image Visual Studio 2015. -# Job 4: Run unit tests on image Visual Studio 2017, without Codecov report. -# Job 5: Run integration tests on image Visual Studio 2017. +# Job 1: Run meta test (common tests) on image Visual Studio 2017. +# Job 2: Run unit tests on image Visual Studio 2017, including Codecov report. +# Job 3: Run integration tests on image Visual Studio 2017. +# Job 4: Run unit tests on image Visual Studio 2015, without Codecov report. +# Job 5: Run integration tests on image Visual Studio 2015. for: - @@ -71,7 +73,7 @@ for: -ExcludeTag @() - - # Job 3 and job 4. + # Job 3 and job 5. matrix: only: - configuration: Integration @@ -86,7 +88,7 @@ for: -ExcludeTag @() - - # Job 2. + # Job 4. matrix: only: - configuration: Unit @@ -99,11 +101,10 @@ for: Invoke-AppveyorTestScriptTask ` -Type 'Default' ` -CodeCoverage ` - -CodeCovIo ` -ExcludeTag @() - - # Job 5. + # Job 2. matrix: only: - configuration: Unit @@ -116,20 +117,28 @@ for: Invoke-AppveyorTestScriptTask ` -Type 'Default' ` -CodeCoverage ` + -CodeCovIo ` -ExcludeTag @() - #---------------------------------# - # deployment configuration # - #---------------------------------# - - # Runs only in job 5, and only when all are successful. - deploy_script: - - ps: | - Invoke-AppVeyorDeployTask - # Runs for all jobs. after_test: - ps: | Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" Invoke-AppveyorAfterTestTask ` -ResourceModuleName $moduleName + + #---------------------------------# + # deployment configuration # + #---------------------------------# + + deploy_script: + - ps: | + # Runs only in job 5 (last job). + if ($env:APPVEYOR_JOB_NUMBER -eq $env:DeployInJobNumber) + { + Invoke-AppVeyorDeployTask + } + else + { + Write-Verbose -Message ('Skipping deploy step. Deploy step was requested to run in job number {0}. Current job number is {1}.' -f $env:DeployInJobNumber, $env:APPVEYOR_JOB_NUMBER) -Verbose + } From 9a762a5e2ab7da4ea06790618dcffe66e7664ed4 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 2 Feb 2019 14:38:04 +0100 Subject: [PATCH 10/12] Update appveyor.yml --- appveyor.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a91f51c18..ad6d3b23b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -127,18 +127,18 @@ after_test: Invoke-AppveyorAfterTestTask ` -ResourceModuleName $moduleName - #---------------------------------# - # deployment configuration # - #---------------------------------# +#---------------------------------# +# deployment configuration # +#---------------------------------# - deploy_script: - - ps: | - # Runs only in job 5 (last job). - if ($env:APPVEYOR_JOB_NUMBER -eq $env:DeployInJobNumber) - { - Invoke-AppVeyorDeployTask - } - else - { - Write-Verbose -Message ('Skipping deploy step. Deploy step was requested to run in job number {0}. Current job number is {1}.' -f $env:DeployInJobNumber, $env:APPVEYOR_JOB_NUMBER) -Verbose - } +# Runs only in a branch (not in PR). +deploy_script: + - ps: | + if ($env:APPVEYOR_JOB_NUMBER -eq $env:DeployInJobNumber) + { + Invoke-AppVeyorDeployTask + } + else + { + Write-Verbose -Message ('Skipping deploy step. Deploy step was requested to run in job number {0}. Current job number is {1}.' -f $env:DeployInJobNumber, $env:APPVEYOR_JOB_NUMBER) -Verbose + } From c3267d8a0b7bfe33aef3f6943770bad9787cd595 Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 2 Feb 2019 17:02:34 +0100 Subject: [PATCH 11/12] Update appveyor.yml --- appveyor.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ad6d3b23b..942efdea7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,10 +22,10 @@ configuration: - Unit - Integration -# The jobs that will excluded based on the combination of configuration name -# and image name. -# This will make sure the meta tests (common tests) are only run on one of the -# images. +# - If one job in the matrix fails, the build will stop (fast_finish). +# - The jobs that will excluded based on the combination of configuration name +# and image name. This will make sure the meta tests (common tests) are only +# run on one of the images. matrix: fast_finish: true exclude: @@ -122,10 +122,10 @@ for: # Runs for all jobs. after_test: -- ps: | - Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorAfterTestTask ` - -ResourceModuleName $moduleName + - ps: | + Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" + Invoke-AppveyorAfterTestTask ` + -ResourceModuleName $moduleName #---------------------------------# # deployment configuration # From 6dd378bf3b3b7aec55c2dd12ab82a72519fffc9b Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Sat, 2 Feb 2019 17:03:45 +0100 Subject: [PATCH 12/12] Update appveyor.yml --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 942efdea7..ff0881da1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -123,9 +123,9 @@ for: # Runs for all jobs. after_test: - ps: | - Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorAfterTestTask ` - -ResourceModuleName $moduleName + Import-Module -Name "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" + Invoke-AppveyorAfterTestTask ` + -ResourceModuleName $moduleName #---------------------------------# # deployment configuration #