From 1e439b8c96f35785b85af7417c16bca762700480 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Fri, 24 Jan 2020 08:44:14 +0100 Subject: [PATCH 1/2] Corrected issue in Project resources --- .../SharePointDsc.SPProjectServerADResourcePoolSync.Tests.ps1 | 2 +- .../SharePointDsc.SPProjectServerAdditionalSettings.tests.ps1 | 4 ++-- .../SharePointDsc.SPProjectServerGlobalPermissions.tests.ps1 | 4 ++-- .../SharePointDsc.SPProjectServerGroup.tests.ps1 | 4 ++-- .../SharePointDsc.SPProjectServerTimeSheetSettings.Tests.ps1 | 2 +- .../SharePointDsc.SPProjectServerUserSyncSettings.tests.ps1 | 2 +- .../SharePointDsc.SPProjectServerWssSettings.tests.ps1 | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerADResourcePoolSync.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerADResourcePoolSync.Tests.ps1 index f15d6d5af..d4e3b0324 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerADResourcePoolSync.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerADResourcePoolSync.Tests.ps1 @@ -70,7 +70,7 @@ try } 16 { - $modulePath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" + $modulePath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" Import-Module -Name (Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $modulePath -Resolve) try diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerAdditionalSettings.tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerAdditionalSettings.tests.ps1 index 7c9d10dfb..130c90708 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerAdditionalSettings.tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerAdditionalSettings.tests.ps1 @@ -70,11 +70,11 @@ try } 16 { - $modulePath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" + $modulePath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" Import-Module -Name (Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $modulePath -Resolve) [System.Reflection.Assembly]::LoadWithPartialName("System.ServiceModel") | Out-Null - $psDllPath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerServices.dll" + $psDllPath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerServices.dll" $fullDllPath = Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $psDllPath -Resolve $bytes = [System.IO.File]::ReadAllBytes($fullDllPath) [System.Reflection.Assembly]::Load($bytes) | Out-Null diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerGlobalPermissions.tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerGlobalPermissions.tests.ps1 index 4725e0824..6907bcf3d 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerGlobalPermissions.tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerGlobalPermissions.tests.ps1 @@ -70,11 +70,11 @@ try } 16 { - $modulePath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" + $modulePath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" Import-Module -Name (Join-Path -Path $global:SPDscHelper.RepoRoot -ChildPath $modulePath -Resolve) [System.Reflection.Assembly]::LoadWithPartialName("System.ServiceModel") | Out-Null - $psDllPath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerServices.dll" + $psDllPath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerServices.dll" $fullDllPath = Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $psDllPath -Resolve $bytes = [System.IO.File]::ReadAllBytes($fullDllPath) [System.Reflection.Assembly]::Load($bytes) | Out-Null diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerGroup.tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerGroup.tests.ps1 index e1c791d15..d1eb73c95 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerGroup.tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerGroup.tests.ps1 @@ -70,11 +70,11 @@ try } 16 { - $modulePath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" + $modulePath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" Import-Module -Name (Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $modulePath -Resolve) [System.Reflection.Assembly]::LoadWithPartialName("System.ServiceModel") | Out-Null - $psDllPath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerServices.dll" + $psDllPath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerServices.dll" $fullDllPath = Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $psDllPath -Resolve $bytes = [System.IO.File]::ReadAllBytes($fullDllPath) [System.Reflection.Assembly]::Load($bytes) | Out-Null diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerTimeSheetSettings.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerTimeSheetSettings.Tests.ps1 index c2fab069f..09caf3cc5 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerTimeSheetSettings.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerTimeSheetSettings.Tests.ps1 @@ -70,7 +70,7 @@ try } 16 { - $modulePath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" + $modulePath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" Import-Module -Name (Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $modulePath -Resolve) Mock -CommandName "Import-Module" -MockWith { } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerUserSyncSettings.tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerUserSyncSettings.tests.ps1 index d4ca91027..a319382ee 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerUserSyncSettings.tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerUserSyncSettings.tests.ps1 @@ -70,7 +70,7 @@ try } 16 { - $modulePath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" + $modulePath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" Import-Module -Name (Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $modulePath -Resolve) Mock -CommandName "Import-Module" -MockWith { } diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerWssSettings.tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerWssSettings.tests.ps1 index 3dabfb480..93271b944 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerWssSettings.tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerWssSettings.tests.ps1 @@ -70,7 +70,7 @@ try } 16 { - $modulePath = "Modules\SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" + $modulePath = "SharePointDsc\Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" Import-Module -Name (Join-Path -Path $Global:SPDscHelper.RepoRoot -ChildPath $modulePath -Resolve) Mock -CommandName "Import-Module" -MockWith { } From 0a2a6b0e5acce4c7dd850a6f4f4e692f77a0e071 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Wed, 12 Feb 2020 20:58:43 +0100 Subject: [PATCH 2/2] Corrected issue in Pester tests --- CHANGELOG.md | 3 ++- .../Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 | 5 +++++ .../SharePointDsc.SPProjectServerConnector.Tests.ps1 | 2 ++ tests/Unit/SharePointDsc/SharePointDsc.Util.Tests.ps1 | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fada73e25..8b4daa5ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - SharePointDsc - - Updated all resources to load Utils module, which broke with the new CI + - Updated all resources and Invoke-SPDscCommand function to automatically + load Utils module, which broke with the new CI - SPConfigWizard - Updated checks in Set method to make sure the resource also runs when a language pack is installed diff --git a/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 index 1dd4d78c1..523ccb2c9 100644 --- a/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 +++ b/SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1 @@ -412,6 +412,11 @@ function Invoke-SPDscCommand Add-PSSnapin Microsoft.SharePoint.PowerShell } + `$SaveVerbosePreference = `$VerbosePreference + `$VerbosePreference = 'SilentlyContinue' + Import-Module "$(Join-Path -Path $PSScriptRoot -ChildPath 'SharePointDsc.Util.psm1')" + `$VerbosePreference = `$SaveVerbosePreference + "@ $invokeArgs = @{ diff --git a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerConnector.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerConnector.Tests.ps1 index af6b683e2..f79845287 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerConnector.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.SPProjectServerConnector.Tests.ps1 @@ -22,6 +22,8 @@ function Invoke-TestSetup -ChildPath "..\UnitTestHelper.psm1" ` -Resolve) + $moduleVersionFolder = ($ModuleVersion -split "-")[0] + $Global:SPDscHelper = New-SPDscUnitTestHelper -SharePointStubModule $SharePointCmdletModule ` -SubModulePath "Modules\SharePointDsc.ProjectServer\ProjectServerConnector.psm1" ` -ExcludeInvokeHelper ` diff --git a/tests/Unit/SharePointDsc/SharePointDsc.Util.Tests.ps1 b/tests/Unit/SharePointDsc/SharePointDsc.Util.Tests.ps1 index dd8fb933c..d97892f68 100644 --- a/tests/Unit/SharePointDsc/SharePointDsc.Util.Tests.ps1 +++ b/tests/Unit/SharePointDsc/SharePointDsc.Util.Tests.ps1 @@ -24,6 +24,8 @@ function Invoke-TestSetup -ChildPath "..\UnitTestHelper.psm1" ` -Resolve) + $moduleVersionFolder = ($ModuleVersion -split "-")[0] + $Global:SPDscHelper = New-SPDscUnitTestHelper -SharePointStubModule $SharePointCmdletModule ` -SubModulePath "Modules\SharePointDsc.Util\SharePointDsc.Util.psm1" ` -ExcludeInvokeHelper `