diff --git a/.vscode/GetTestCoverage.ps1 b/.vscode/GetTestCoverage.ps1 index 458df495a2..0b3a88ff68 100644 --- a/.vscode/GetTestCoverage.ps1 +++ b/.vscode/GetTestCoverage.ps1 @@ -2,31 +2,38 @@ param( [Parameter(Mandatory = $true)] [string] - $UnitTestFilePath, - - [Parameter(Mandatory = $true)] - [string] - $CmdletModule = (Join-Path -Path $PSScriptRoot ` - -ChildPath '..\Stubs\Microsoft365.psm1' ` - -Resolve) + $UnitTestFilePath ) -if ($UnitTestFilePath.EndsWith('Tests.ps1')) -{ +$moduleName = 'Pester' +$minVersion = '5.5.0' - $pesterParameters = @{ - Path = $unitTestFilePath - Parameters = @{ - CmdletModule = $CmdletModule - } - } +$module = Get-Module -ListAvailable | Where-Object { $_.Name -eq $moduleName -and $_.Version -ge $minVersion } +if ($module -ne $null) +{ + Write-Output "Module $moduleName with version greater than or equal to $minVersion found." +} +else +{ + Write-Output "Module $moduleName with version greater than or equal to $minVersion not found." + Write-Output 'Please install the module using the following command:' + Write-Output "Install-Module -Name $moduleName -MinimumVersion $minVersion" + return +} + +if ($UnitTestFilePath.EndsWith('Tests.ps1')) +{ $unitTest = Get-Item -Path $UnitTestFilePath $unitTestName = "$($unitTest.Name.Split('.')[1])" - $unitTestFilePath = (Join-Path -Path $PSScriptRoot ` + $coveragePath = (Join-Path -Path $PSScriptRoot ` -ChildPath "..\Modules\Microsoft365DSC\DSCResources\MSFT_$($unitTestName)\MSFT_$($unitTestName).psm1" ` -Resolve) - Invoke-Pester -Script $pesterParameters -CodeCoverage $UnitTestFilePath -Verbose + $config = New-PesterConfiguration + $config.Run.Path = $UnitTestFilePath + $config.CodeCoverage.Enabled = $true + $config.CodeCoverage.Path = $coveragePath + Invoke-Pester -Configuration $config } diff --git a/.vscode/launch.json b/.vscode/launch.json index 3bd859a536..1258adeb13 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,9 +6,7 @@ "request": "launch", "name": "Run current unit test", "script": "${file}", - "args": [ - "${workspaceRoot}/Tests/Unit/Stubs/Microsoft365.psm1" - ], + "args": [], "cwd": "${file}", "createTemporaryIntegratedConsole": true }, @@ -18,10 +16,25 @@ "name": "Get current unit test code overage", "script": "${workspaceRoot}/.vscode/GetTestCoverage.ps1", "args": [ - "${file}", - "${workspaceRoot}/Tests/Unit/Stubs/Microsoft365.psm1" + "${file}" ], "createTemporaryIntegratedConsole": true + }, + { + "type": "PowerShell", + "request": "launch", + "name": "Run all QA tests", + "script": "Import-Module '${workspaceRoot}/Tests/TestHarness.psm1'; $QaResults = Invoke-QualityChecksHarness ", + "args": [], + "createTemporaryIntegratedConsole": true + }, + { + "type": "PowerShell", + "request": "launch", + "name": "Run all Unit Tests", + "script": "Import-Module '${workspaceRoot}/Tests/TestHarness.psm1'; $UnitResults = Invoke-TestHarness", + "args": [], + "createTemporaryIntegratedConsole": true } ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bb9b65211..561a577b7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,9 @@ FIXES [#3962](https://github.com/microsoft/Microsoft365DSC/issues/3962) * SPOAccessControlSettings * Added support for the ConditionalAccessPolicy parameter based on the PNP Module +* TeamsCallQueue + * Reduce the number of Calls for Export using new cache pattern + FIXES [[#4191](https://github.com/microsoft/Microsoft365DSC/issues/4192)] * TeamsGuestMeetingConfiguration * Added the missing parameter AllowTranscription. FIXES [#4363](https://github.com/microsoft/Microsoft365DSC/issues/4363) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 index bedf6c253f..45cb5d2119 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 @@ -249,8 +249,18 @@ function Get-TargetResource $nullReturn.Ensure = 'Absent' try { - $queue = Get-CsCallQueue -NameFilter $Name ` - -ErrorAction SilentlyContinue | Where-Object -FilterScript {$_.Name -eq $Name} + if (-not $Script:ExportMode) + { + Write-Host -Message "Getting Office 365 queue $Name" + $queue = Get-CsCallQueue -NameFilter $Name ` + -ErrorAction SilentlyContinue | Where-Object -FilterScript {$_.Name -eq $Name} + } + else + { + Write-Host -Message "Retrieving queue $Name from the exported instances" + $queue = $Script:exportedInstances | Where-Object -FilterScript {$_.Name -eq $Name} + } + if ($null -eq $queue) {