diff --git a/.vscode/RunAllTests.ps1 b/.vscode/RunAllTests.ps1 deleted file mode 100644 index e05ced2c..00000000 --- a/.vscode/RunAllTests.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -$repoRoot = Split-Path -Path (Split-Path -Path $Script:MyInvocation.MyCommand.Path) -$dscResourceTestsPath = Join-Path -Path $repoRoot -ChildPath '\Modules\ComputerManagementDsc\DSCResource.Tests\' - -if ((-not (Test-Path -Path $dscResourceTestsPath)) -or ` - (-not (Test-Path -Path (Join-Path -Path $dscResourceTestsPath -ChildPath 'TestHelper.psm1')))) -{ - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', $dscResourceTestsPath) -} - -Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\Tests\TestHarness.psm1' -Resolve) -$dscTestsPath = Join-Path -Path $dscResourceTestsPath -ChildPath 'Meta.Tests.ps1' -Invoke-TestHarness -DscTestsPath $dscTestsPath diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 86c32f38..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "PowerShell", - "type": "PowerShell", - "request": "launch", - "program": "${file}", - "args": [], - "cwd": "${file}" - }, - { - "name": "Run all tests", - "type": "PowerShell", - "request": "launch", - "program": "${workspaceRoot}/.vscode/RunAllTests.ps1" - } - ] -} diff --git a/CHANGELOG.md b/CHANGELOG.md index bb512d42..3fc6747e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ - IdleWaitTimeout returned from Get-TargetResource always null - Fixes [Issue #186](https://github.com/PowerShell/ComputerManagementDsc/issues/186). - Added BuiltInAccount Property to allow running task as one of the build in service accounts - Fixes [Issue #130](https://github.com/PowerShell/ComputerManagementDsc/issues/130). +- Refactored module folder structure to move resource to root folder of + repository and remove test harness - fixes [Issue #188](https://github.com/PowerShell/ComputerManagementDsc/issues/188). +- Added a CODE\_OF\_CONDUCT.md with the same content as in the README.md and + linked to it from README.MD instead. +- Updated test header for all unit tests to version 1.2.4. +- Updated test header for all imtegration to version 1.3.3. +- Enabled example publish to PowerShell Gallery by adding `gallery_api` + environment variable to `AppVeyor.yml`. ## 6.3.0.0 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..1d5c9eab --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,6 @@ +# Code of conduct + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional +questions or comments. diff --git a/Modules/ComputerManagementDsc/ComputerManagementDsc.psd1 b/ComputerManagementDsc.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/ComputerManagementDsc.psd1 rename to ComputerManagementDsc.psd1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/MSFT_Computer.psm1 b/DSCResources/MSFT_Computer/MSFT_Computer.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/MSFT_Computer.psm1 rename to DSCResources/MSFT_Computer/MSFT_Computer.psm1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof b/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof rename to DSCResources/MSFT_Computer/MSFT_Computer.schema.mof diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/README.md b/DSCResources/MSFT_Computer/README.md similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/README.md rename to DSCResources/MSFT_Computer/README.md diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 b/DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 rename to DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 b/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 rename to DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof b/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof rename to DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_OfflineDomainJoin/README.md b/DSCResources/MSFT_OfflineDomainJoin/README.md similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_OfflineDomainJoin/README.md rename to DSCResources/MSFT_OfflineDomainJoin/README.md diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 b/DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 rename to DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 b/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 rename to DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof b/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof rename to DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/README.md b/DSCResources/MSFT_PowerPlan/README.md similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/README.md rename to DSCResources/MSFT_PowerPlan/README.md diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl b/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl rename to DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 b/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 rename to DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 b/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 rename to DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof b/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof rename to DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_PowerShellExecutionPolicy/README.md b/DSCResources/MSFT_PowerShellExecutionPolicy/README.md similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_PowerShellExecutionPolicy/README.md rename to DSCResources/MSFT_PowerShellExecutionPolicy/README.md diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 b/DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 rename to DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 b/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 rename to DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof b/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof rename to DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/README.md b/DSCResources/MSFT_ScheduledTask/README.md similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/README.md rename to DSCResources/MSFT_ScheduledTask/README.md diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 b/DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 rename to DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 b/DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 rename to DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof b/DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof rename to DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_TimeZone/README.md b/DSCResources/MSFT_TimeZone/README.md similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_TimeZone/README.md rename to DSCResources/MSFT_TimeZone/README.md diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_TimeZone/en-us/MSFT_TimeZone.strings.psd1 b/DSCResources/MSFT_TimeZone/en-us/MSFT_TimeZone.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_TimeZone/en-us/MSFT_TimeZone.strings.psd1 rename to DSCResources/MSFT_TimeZone/en-us/MSFT_TimeZone.strings.psd1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 b/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 rename to DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof b/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof rename to DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_VirtualMemory/README.md b/DSCResources/MSFT_VirtualMemory/README.md similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_VirtualMemory/README.md rename to DSCResources/MSFT_VirtualMemory/README.md diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 b/DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 rename to DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 b/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 rename to DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof b/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof rename to DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/README.md b/DSCResources/MSFT_WindowsEventLog/README.md similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/README.md rename to DSCResources/MSFT_WindowsEventLog/README.md diff --git a/Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 b/DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 rename to DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 b/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 rename to Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 b/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 rename to Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 b/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 rename to Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 b/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 rename to Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 b/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 rename to Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 b/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 rename to Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 b/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 rename to Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 b/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 rename to Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 b/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 rename to Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 b/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 rename to Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 b/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 rename to Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 b/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 rename to Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 b/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 rename to Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 b/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 rename to Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 b/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 rename to Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 b/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 rename to Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 b/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 rename to Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 b/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 rename to Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 b/Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 rename to Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 b/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 rename to Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 b/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 rename to Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 b/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 rename to Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 b/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 rename to Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 b/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 rename to Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 b/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 rename to Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 b/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 rename to Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 b/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 rename to Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 b/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 rename to Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 b/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 rename to Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 b/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 rename to Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 b/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 rename to Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 b/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 rename to Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 b/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 rename to Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 b/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 rename to Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 b/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 similarity index 100% rename from Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 rename to Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 diff --git a/Modules/ComputerManagementDsc/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 b/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 rename to Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 diff --git a/Modules/ComputerManagementDsc/Modules/ComputerManagementDsc.Common/SetTimeZone.cs b/Modules/ComputerManagementDsc.Common/SetTimeZone.cs similarity index 100% rename from Modules/ComputerManagementDsc/Modules/ComputerManagementDsc.Common/SetTimeZone.cs rename to Modules/ComputerManagementDsc.Common/SetTimeZone.cs diff --git a/Modules/ComputerManagementDsc/Modules/ComputerManagementDsc.Common/en-us/ComputerManagementDsc.Common.strings.psd1 b/Modules/ComputerManagementDsc.Common/en-us/ComputerManagementDsc.Common.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc/Modules/ComputerManagementDsc.Common/en-us/ComputerManagementDsc.Common.strings.psd1 rename to Modules/ComputerManagementDsc.Common/en-us/ComputerManagementDsc.Common.strings.psd1 diff --git a/Modules/ComputerManagementDsc/Modules/ComputerManagementDsc.ResourceHelper/ComputerManagementDsc.ResourceHelper.psm1 b/Modules/ComputerManagementDsc.ResourceHelper/ComputerManagementDsc.ResourceHelper.psm1 similarity index 100% rename from Modules/ComputerManagementDsc/Modules/ComputerManagementDsc.ResourceHelper/ComputerManagementDsc.ResourceHelper.psm1 rename to Modules/ComputerManagementDsc.ResourceHelper/ComputerManagementDsc.ResourceHelper.psm1 diff --git a/README.md b/README.md index 054d8bec..db3b7eea 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,7 @@ The **ComputerManagementDsc** module contains the following resources: - **WindowsEventLog**: This resource allows configuration of a specified Windows Event Log. -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any -additional questions or comments. +This project has adopted [this code of conduct](CODE_OF_CONDUCT.md). ## Documentation and Examples diff --git a/Tests/Integration/ComputerManagementDsc.Common.Tests.ps1 b/Tests/Integration/ComputerManagementDsc.Common.Tests.ps1 index cb58f841..a99b5a2b 100644 --- a/Tests/Integration/ComputerManagementDsc.Common.Tests.ps1 +++ b/Tests/Integration/ComputerManagementDsc.Common.Tests.ps1 @@ -1,17 +1,17 @@ +#region HEADER $script:ModuleName = 'ComputerManagementDsc.Common' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -#region HEADER -# Unit Test Template Version: 1.1.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force Import-Module (Join-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'Modules' -ChildPath $script:ModuleName)) -ChildPath "$script:ModuleName.psm1") -Force #endregion HEADER diff --git a/Tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 b/Tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 index 98d5f918..c88c4182 100644 --- a/Tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 @@ -1,34 +1,33 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_PowerShellExecutionPolicy' - #region HEADER -# Integration Test Template Version: 1.1.1 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_PowerShellExecutionPolicy' + +# Integration Test Template Version: 1.3.3 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` -TestType Integration - #endregion try { #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile - Describe "$($script:DSCResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { #region DEFAULT TESTS It 'Should compile and apply the MOF without throwing' { { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + & "$($script:dscResourceName)_Config" -OutputPath $TestDrive $startDscConfigurationParameters = @{ Path = $TestDrive @@ -52,7 +51,7 @@ try It 'Should have set the resource and all the parameters should match' { $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq "$($script:DSCResourceName)_Config" + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" } $current.ExecutionPolicy | Should Be 'RemoteSigned' $current.ExecutionPolicyScope | Should Be 'LocalMachine' diff --git a/Tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 b/Tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 index 53fc756c..831913c8 100644 --- a/Tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 @@ -1,32 +1,36 @@ #Requires -Version 5.0 -$Script:DSCModuleName = 'ComputerManagementDsc' -$Script:DSCResourceName = 'MSFT_ScheduledTask' #region HEADER -# Integration Test Template Version: 1.1.1 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_ScheduledTask' + +# Integration Test Template Version: 1.3.3 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $Script:DSCModuleName ` - -DSCResourceName $Script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` -TestType Integration #endregion Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +# Load the ComputerManagementDsc.Common module to use Set-TimezoneId function +Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'Modules' -ChildPath 'ComputerManagementDsc.Common')) -Force + # Begin Testing try { - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($Script:DSCResourceName).config.ps1" + $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $ConfigFile #region Pester Tests - Describe $Script:DSCResourceName { + Describe $script:dscResourceName { $contexts = @{ Once = 'ScheduledTaskOnce' diff --git a/Tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 b/Tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 index 3d908f88..837da24b 100644 --- a/Tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 @@ -1,20 +1,21 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_TimeZone' - #region HEADER -# Integration Test Template Version: 1.1.1 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_TimeZone' + +# Integration Test Template Version: 1.3.3 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` -TestType Integration +#endregion # Store the test machine timezone $currentTimeZone = & tzutil.exe /g @@ -26,10 +27,10 @@ tzutil.exe /s 'Eastern Standard Time' try { #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile -Verbose -ErrorAction Stop - Describe "$($script:DSCResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { $configData = @{ AllNodes = @( @{ @@ -42,7 +43,7 @@ try It 'Should compile and apply the MOF without throwing' { { - & "$($script:DSCResourceName)_Config" ` + & "$($script:dscResourceName)_Config" ` -OutputPath $TestDrive ` -ConfigurationData $configData @@ -62,7 +63,7 @@ try It 'Should have set the configuration and all the parameters should match' { $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq "$($script:DSCResourceName)_Config" + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" } $current.TimeZone | Should -Be $configData.AllNodes[0].TimeZone $current.IsSingleInstance | Should -Be $configData.AllNodes[0].IsSingleInstance diff --git a/Tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 b/Tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 index 50971a06..d9f6b901 100644 --- a/Tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 @@ -1,31 +1,30 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_VirtualMemory' - #region HEADER -# Integration Test Template Version: 1.1.1 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_VirtualMemory' + +# Integration Test Template Version: 1.3.3 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` -TestType Integration - #endregion # Using try/finally to always cleanup. try { #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile - Describe "$($script:DSCResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { Context 'Set page file to automatically managed' { $CurrentConfig = 'setToAuto' diff --git a/Tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 b/Tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 index 996408e0..db2a0c5a 100644 --- a/Tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 @@ -1,30 +1,29 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_WindowsEventLog' - #region HEADER -# Integration Test Template Version: 1.1.1 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_WindowsEventLog' + +# Integration Test Template Version: 1.3.3 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` -TestType Integration - #endregion # Using try/finally to always cleanup. try { #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile - Describe "$($script:DSCResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { Context 'Set Windows Event Log to Logmode Retain' { $CurrentConfig = 'MSFT_WindowsEventLog_RetainSize' diff --git a/Tests/TestHarness.psm1 b/Tests/TestHarness.psm1 deleted file mode 100644 index 3459360d..00000000 --- a/Tests/TestHarness.psm1 +++ /dev/null @@ -1,66 +0,0 @@ -function Invoke-TestHarness -{ - [CmdletBinding()] - param - ( - [System.String] - $TestResultsFile, - - [System.String] - $DscTestsPath - ) - - Write-Verbose -Message 'Commencing all ComputerManagementDsc tests' - - $repoDir = Join-Path -Path $PSScriptRoot -ChildPath '..\' -Resolve - - $testCoverageFiles = @() - Get-ChildItem -Path "$repoDir\modules\ComputerManagementDsc\DSCResources\**\*.psm1" -Recurse | ForEach-Object { - if ($_.FullName -notlike '*\DSCResource.Tests\*') { - $testCoverageFiles += $_.FullName - } - } - - $testResultSettings = @{ } - if ([String]::IsNullOrEmpty($TestResultsFile) -eq $false) { - $testResultSettings.Add('OutputFormat', 'NUnitXml' ) - $testResultSettings.Add('OutputFile', $TestResultsFile) - } - - Import-Module -Name "$repoDir\modules\ComputerManagementDsc\ComputerManagementDsc.psd1" - $testsToRun = @() - - # Run Unit Tests - $unitTestsPath = Join-Path -Path $repoDir -ChildPath 'Tests\Unit' - $testsToRun += @( (Get-ChildItem -Path $unitTestsPath).FullName ) - - # Integration Tests - $integrationTestsPath = Join-Path -Path $repoDir -ChildPath 'Tests\Integration' - $testsToRun += @( (Get-ChildItem -Path $integrationTestsPath -Filter '*.Tests.ps1').FullName ) - - # DSC Common Tests - if ($PSBoundParameters.ContainsKey('DscTestsPath') -eq $true) - { - $getChildItemParameters = @{ - Path = $DscTestsPath - Recurse = $true - Filter = '*.Tests.ps1' - } - - # Get all tests '*.Tests.ps1'. - $commonTestFiles = Get-ChildItem @getChildItemParameters - - # Remove DscResource.Tests unit and integration tests. - $commonTestFiles = $commonTestFiles | Where-Object -FilterScript { - $_.FullName -notmatch 'DSCResource.Tests\\Tests' - } - - $testsToRun += @( $commonTestFiles.FullName ) - } - - $results = Invoke-Pester -Script $testsToRun ` - -CodeCoverage $testCoverageFiles ` - -PassThru @testResultSettings - - return $results -} diff --git a/Tests/Unit/ComputerManagementDsc.Common.Tests.ps1 b/Tests/Unit/ComputerManagementDsc.Common.Tests.ps1 index c8908dde..8f8fccb5 100644 --- a/Tests/Unit/ComputerManagementDsc.Common.Tests.ps1 +++ b/Tests/Unit/ComputerManagementDsc.Common.Tests.ps1 @@ -1,17 +1,17 @@ +#region HEADER $script:ModuleName = 'ComputerManagementDsc.Common' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -#region HEADER -# Unit Test Template Version: 1.1.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force Import-Module (Join-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'Modules' -ChildPath $script:ModuleName)) -ChildPath "$script:ModuleName.psm1") -Force #endregion HEADER diff --git a/Tests/Unit/MSFT_Computer.Tests.ps1 b/Tests/Unit/MSFT_Computer.Tests.ps1 index 0bc8b809..1db05a0e 100644 --- a/Tests/Unit/MSFT_Computer.Tests.ps1 +++ b/Tests/Unit/MSFT_Computer.Tests.ps1 @@ -1,21 +1,23 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_Computer' +#region HEADER +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_Computer' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` -TestType Unit #endregion HEADER @@ -24,10 +26,10 @@ try { #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'MSFT_Computer' + InModuleScope $script:dscResourceName { + $script:dscResourceName = 'MSFT_Computer' - Describe $script:DSCResourceName { + Describe $script:dscResourceName { # A real password isn't needed here - use this next line to avoid triggering PSSA rule $securePassword = New-Object -Type SecureString $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'USER', $securePassword @@ -40,7 +42,7 @@ try 'name' } - Context "$($script:DSCResourceName)\Test-TargetResource" { + Context "$($script:dscResourceName)\Test-TargetResource" { Mock -CommandName Get-WMIObject -MockWith { [PSCustomObject] @{ DomainName = 'ContosoLtd' @@ -442,7 +444,7 @@ try } } - Context "$($script:DSCResourceName)\Get-TargetResource" { + Context "$($script:dscResourceName)\Get-TargetResource" { It 'should not throw' { { Get-TargetResource ` @@ -477,7 +479,7 @@ try } } - Context "$($script:DSCResourceName)\Set-TargetResource" { + Context "$($script:dscResourceName)\Set-TargetResource" { Mock -CommandName Rename-Computer Mock -CommandName Add-Computer Mock -CommandName Set-CimInstance @@ -952,7 +954,7 @@ try } } - Context "$($script:DSCResourceName)\Get-ComputerDomain" { + Context "$($script:dscResourceName)\Get-ComputerDomain" { It 'Returns domain netbios or DNS name if domain member' { Mock -CommandName Get-CimInstance -ParameterFilter { $ClassName -eq 'Win32_ComputerSystem' } -MockWith { [PSCustomObject] @{ @@ -1034,7 +1036,7 @@ try } } - Context "$($script:DSCResourceName)\Get-LogonServer" { + Context "$($script:dscResourceName)\Get-LogonServer" { It 'Should return a non-empty string' { Get-LogonServer | Should -Not -BeNullOrEmpty } diff --git a/Tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 b/Tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 index 4964c322..b98a62e2 100644 --- a/Tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 +++ b/Tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 @@ -1,21 +1,23 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_OfflineDomainJoin' +#region HEADER +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_OfflineDomainJoin' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` -TestType Unit #endregion HEADER @@ -23,8 +25,8 @@ $TestEnvironment = Initialize-TestEnvironment ` try { #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'MSFT_OfflineDomainJoin' + InModuleScope $script:dscResourceName { + $script:dscResourceName = 'MSFT_OfflineDomainJoin' $testOfflineDomainJoin = @{ IsSingleInstance = 'Yes' @@ -32,7 +34,7 @@ try Verbose = $true } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe "$($script:dscResourceName)\Get-TargetResource" { It 'Should return the correct values' { $result = Get-TargetResource ` @TestOfflineDomainJoin @@ -42,7 +44,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe "$($script:dscResourceName)\Set-TargetResource" { Context 'Domain is not joined' { Mock -CommandName Test-Path -MockWith { return $true @@ -82,7 +84,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe "$($script:dscResourceName)\Test-TargetResource" { Context 'Domain is not joined' { Mock -CommandName Test-Path -MockWith { return $true @@ -145,7 +147,7 @@ try } } - Describe "$($script:DSCResourceName)\Join-Domain" { + Describe "$($script:dscResourceName)\Join-Domain" { Context 'Domain Join successful' { Mock -CommandName djoin.exe -MockWith { $script:LASTEXITCODE = 0 diff --git a/Tests/Unit/MSFT_PowerPlan.Tests.ps1 b/Tests/Unit/MSFT_PowerPlan.Tests.ps1 index e21c39a2..5ff18b74 100644 --- a/Tests/Unit/MSFT_PowerPlan.Tests.ps1 +++ b/Tests/Unit/MSFT_PowerPlan.Tests.ps1 @@ -1,21 +1,23 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_PowerPlan' +#region HEADER +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_PowerPlan' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` -TestType Unit #endregion HEADER @@ -28,7 +30,7 @@ function Invoke-TestCleanup try { # Assign the localized data from the module into a local variable - $LocalizedData = InModuleScope $script:DSCResourceName { + $LocalizedData = InModuleScope $script:dscResourceName { $LocalizedData } @@ -46,7 +48,7 @@ try } ) - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe "$($script:dscResourceName)\Get-TargetResource" { Context 'When the system is in the desired present state' { BeforeEach { Mock ` @@ -57,7 +59,7 @@ try Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } } ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable Mock ` @@ -65,7 +67,7 @@ try -MockWith { return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable } @@ -93,7 +95,7 @@ try Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } } ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable Mock ` @@ -101,7 +103,7 @@ try -MockWith { return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' } ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable } @@ -124,7 +126,7 @@ try BeforeEach { Mock ` -CommandName Get-PowerPlan ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable } @@ -146,7 +148,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetReource" { + Describe "$($script:dscResourceName)\Set-TargetReource" { BeforeEach { Mock ` -CommandName Get-PowerPlan ` @@ -156,12 +158,12 @@ try Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } } ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable Mock ` -CommandName Set-ActivePowerPlan ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable } @@ -175,7 +177,7 @@ try Set-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose - Assert-MockCalled -CommandName Get-PowerPlan -Exactly -Times 1 -Scope It -ModuleName $script:DSCResourceName + Assert-MockCalled -CommandName Get-PowerPlan -Exactly -Times 1 -Scope It -ModuleName $script:dscResourceName } It 'Should call Set-ActivePowerPlan once (power plan specified as )' -TestCases $testCases { @@ -192,7 +194,7 @@ try -Exactly ` -Times 1 ` -Scope It ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -ParameterFilter {$PowerPlanGuid -eq '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'} } } @@ -201,7 +203,7 @@ try BeforeEach { Mock ` -CommandName Get-PowerPlan ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable } @@ -221,7 +223,7 @@ try Assert-VerifiableMock } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe "$($script:dscResourceName)\Test-TargetResource" { Context 'When the system is in the desired present state' { BeforeEach { Mock ` @@ -232,7 +234,7 @@ try Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } } ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable Mock ` @@ -240,7 +242,7 @@ try -MockWith { return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable } @@ -266,7 +268,7 @@ try Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } } ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable Mock ` @@ -274,7 +276,7 @@ try -MockWith { return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' } ` - -ModuleName $script:DSCResourceName ` + -ModuleName $script:dscResourceName ` -Verifiable } diff --git a/Tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 b/Tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 index 7052d307..0528b2de 100644 --- a/Tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 +++ b/Tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 @@ -1,22 +1,23 @@ #region HEADER -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_PowershellExecutionPolicy' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_PowershellExecutionPolicy' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` -TestType Unit #endregion HEADER @@ -41,11 +42,11 @@ try The InModuleScope command allows you to perform white-box unit testing on the internal (non-exported) code of a Script Module. #> - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'MSFT_PowershellExecutionPolicy' + InModuleScope $script:dscResourceName { + $script:dscResourceName = 'MSFT_PowershellExecutionPolicy' #region Function Get-TargetResource - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe "$($script:dscResourceName)\Get-TargetResource" { It 'Throws when passed an invalid execution policy' { { Get-TargetResource -ExecutionPolicy 'badParam' -Scope 'LocalMachine' } | Should -Throw $Script:invalidPolicyThrowMessage @@ -70,7 +71,7 @@ try #endregion #region Function Test-TargetResource - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe "$($script:dscResourceName)\Test-TargetResource" { It 'Throws when passed an invalid execution policy' { { Test-TargetResource -ExecutionPolicy 'badParam' -Scope 'LocalMachine' } | Should -Throw $Script:invalidPolicyThrowMessage @@ -102,7 +103,7 @@ try #endregion #region Function Set-TargetResource - Describe "$script:DSCResourceName\Set-TargetResource" { + Describe "$script:dscResourceName\Set-TargetResource" { It 'Throws when passed an invalid execution policy' { { Set-TargetResource -ExecutionPolicy 'badParam' -Scope 'LocalMachine' } | Should -Throw $Script:invalidPolicyThrowMessage diff --git a/Tests/Unit/MSFT_ScheduledTask.Tests.ps1 b/Tests/Unit/MSFT_ScheduledTask.Tests.ps1 index 92f59bd6..348b4a0b 100644 --- a/Tests/Unit/MSFT_ScheduledTask.Tests.ps1 +++ b/Tests/Unit/MSFT_ScheduledTask.Tests.ps1 @@ -3,24 +3,26 @@ param ( ) -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_ScheduledTask' +#region HEADER +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_ScheduledTask' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` -TestType Unit #endregion HEADER @@ -32,8 +34,8 @@ try { #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'MSFT_ScheduledTask' + InModuleScope $script:dscResourceName { + $script:dscResourceName = 'MSFT_ScheduledTask' # Function to allow mocking pipeline input function Register-ScheduledTask @@ -87,7 +89,7 @@ try ) } - Describe $script:DSCResourceName { + Describe $script:dscResourceName { BeforeAll { Mock -CommandName Register-ScheduledTask Mock -CommandName Set-ScheduledTask diff --git a/Tests/Unit/MSFT_TimeZone.Tests.ps1 b/Tests/Unit/MSFT_TimeZone.Tests.ps1 index 5f49cab1..284a825f 100644 --- a/Tests/Unit/MSFT_TimeZone.Tests.ps1 +++ b/Tests/Unit/MSFT_TimeZone.Tests.ps1 @@ -1,33 +1,34 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_TimeZone' +#region HEADER +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_TimeZone' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force +Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` -TestType Unit #endregion HEADER - # Begin Testing try { #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'MSFT_TimeZone' + InModuleScope $script:dscResourceName { + $script:dscResourceName = 'MSFT_TimeZone' - Describe "$($script:DSCResourceName) MOF single instance schema" { + Describe "$($script:dscResourceName) MOF single instance schema" { It 'Should have mandatory IsSingleInstance parameter and one other parameter' { $timeZoneResource = Get-DscResource -Name TimeZone @@ -41,7 +42,7 @@ try } } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe "$($script:dscResourceName)\Get-TargetResource" { Mock ` -CommandName Get-TimeZoneId ` -MockWith { 'Pacific Standard Time' } @@ -60,7 +61,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe "$($script:dscResourceName)\Set-TargetResource" { Mock ` -CommandName Set-TimeZoneId @@ -97,7 +98,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe "$($script:dscResourceName)\Test-TargetResource" { Mock ` -ModuleName ComputerManagementDsc.Common ` -CommandName Get-TimeZoneId ` diff --git a/Tests/Unit/MSFT_VirtualMemory.Tests.ps1 b/Tests/Unit/MSFT_VirtualMemory.Tests.ps1 index 3cad50aa..b1aa40fc 100644 --- a/Tests/Unit/MSFT_VirtualMemory.Tests.ps1 +++ b/Tests/Unit/MSFT_VirtualMemory.Tests.ps1 @@ -1,34 +1,38 @@ #region HEADER -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_VirtualMemory' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_VirtualMemory' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` -TestType Unit #endregion HEADER -function Invoke-TestSetup { +function Invoke-TestSetup +{ } -function Invoke-TestCleanup { +function Invoke-TestCleanup +{ Restore-TestEnvironment -TestEnvironment $TestEnvironment } # Begin Testing -try { +try +{ Invoke-TestSetup InModuleScope 'MSFT_VirtualMemory' { @@ -36,7 +40,8 @@ try { Remove-CimInstance overridden to enable PSObject to be passed to mocked version. #> - function Remove-CimInstance { + function Remove-CimInstance + { param ( $InputObject @@ -57,14 +62,14 @@ try { $mockAutomaticPagefileEnabled = { [PSObject] @{ AutomaticManagedPageFile = $true - Name = $testPageFileName + Name = $testPageFileName } } $mockAutomaticPagefileDisabled = { [PSObject] @{ AutomaticManagedPageFile = $false - Name = $testPageFileName + Name = $testPageFileName } } @@ -82,27 +87,27 @@ try { $parameterFilterSetPageFileSetting = { $Namespace -eq 'root\cimv2' -and ` - $Query -eq "Select * from Win32_PageFileSetting where SettingID='pagefile.sys @ $testDrive'" -and ` - $Property.InitialSize -eq $testInitialSize -and ` - $Property.MaximumSize -eq $testMaximumSize + $Query -eq "Select * from Win32_PageFileSetting where SettingID='pagefile.sys @ $testDrive'" -and ` + $Property.InitialSize -eq $testInitialSize -and ` + $Property.MaximumSize -eq $testMaximumSize } $parameterFilterEnableAutoManagePaging = { $Namespace -eq 'root\cimv2' -and ` - $Query -eq 'Select * from Win32_ComputerSystem' -and ` - $Property.AutomaticManagedPageFile -eq $True + $Query -eq 'Select * from Win32_ComputerSystem' -and ` + $Property.AutomaticManagedPageFile -eq $True } $parameterFilterDisableAutoManagePaging = { $Namespace -eq 'root\cimv2' -and ` - $Query -eq 'Select * from Win32_ComputerSystem' -and ` - $Property.AutomaticManagedPageFile -eq $False + $Query -eq 'Select * from Win32_ComputerSystem' -and ` + $Property.AutomaticManagedPageFile -eq $False } $parameterFilterNewPageFileSetting = { $Namespace -eq 'root\cimv2' -and ` - $ClassName -eq 'Win32_PageFileSetting' -and ` - $Property.Name -eq $testPageFileName + $ClassName -eq 'Win32_PageFileSetting' -and ` + $Property.Name -eq $testPageFileName } $parameterFilterComputerSystem = { @@ -111,7 +116,7 @@ try { $parameterFilterPageFileSetting = { $ClassName -eq 'Win32_PageFileSetting' -and ` - $Filter -eq "SettingID='pagefile.sys @ $testDrive'" + $Filter -eq "SettingID='pagefile.sys @ $testDrive'" } Describe 'MSFT_VirtualMemory\Get-TargetResource' { @@ -180,12 +185,12 @@ try { -CommandName Get-PageFileSetting ` -ParameterFilter $parameterFilterGetPageFileSetting ` -MockWith { - [PSObject] @{ - InitialSize = 0 - MaximumSize = 0 - Name = "$testDrive\" - } + [PSObject] @{ + InitialSize = 0 + MaximumSize = 0 + Name = "$testDrive\" } + } It 'Should return a expected type and drive letter' { $result = Get-TargetResource @testParameters @@ -216,12 +221,12 @@ try { -CommandName Get-PageFileSetting ` -ParameterFilter $parameterFilterGetPageFileSetting ` -MockWith { - [PSObject] @{ - InitialSize = 10 - MaximumSize = 20 - Name = "$testDrive\" - } + [PSObject] @{ + InitialSize = 10 + MaximumSize = 20 + Name = "$testDrive\" } + } It 'Should return expected type and drive letter' { $result = Get-TargetResource @testParameters @@ -257,10 +262,10 @@ try { Mock ` -CommandName Join-Path ` -ParameterFilter { - $Path -eq "$testDrive\" -and ` + $Path -eq "$testDrive\" -and ` $ChildPath -eq 'pagefile.sys' - } ` - -MockWith { "$testDrive\pagefile.sys"} + } ` + -MockWith { "$testDrive\pagefile.sys" } } @@ -321,10 +326,10 @@ try { Mock ` -CommandName Set-PageFileSetting ` -ParameterFilter { - $Drive -eq $testDrive -and ` + $Drive -eq $testDrive -and ` $InitialSize -eq $testInitialSize -and ` $MaximumSize -eq $testMaximumSize - } + } It 'Should not throw an exception' { $testParameters = @{ @@ -362,10 +367,10 @@ try { Assert-MockCalled ` -CommandName Set-PageFileSetting ` -ParameterFilter { - $Drive -eq $testDrive -and ` + $Drive -eq $testDrive -and ` $InitialSize -eq $testInitialSize -and ` $MaximumSize -eq $testMaximumSize - } ` + } ` -Exactly -Times 1 } } @@ -392,10 +397,10 @@ try { Mock ` -CommandName Set-PageFileSetting ` -ParameterFilter { - $Drive -eq $testDrive -and ` + $Drive -eq $testDrive -and ` $InitialSize -eq $testInitialSize -and ` $MaximumSize -eq $testMaximumSize - } + } It 'Should not throw an exception' { $testParameters = @{ @@ -433,10 +438,10 @@ try { Assert-MockCalled ` -CommandName Set-PageFileSetting ` -ParameterFilter { - $Drive -eq $testDrive -and ` + $Drive -eq $testDrive -and ` $InitialSize -eq $testInitialSize -and ` $MaximumSize -eq $testMaximumSize - } ` + } ` -Exactly -Times 1 } } @@ -463,14 +468,14 @@ try { Mock ` -CommandName Set-PageFileSetting ` -ParameterFilter { - $Drive -eq $testDrive - } + $Drive -eq $testDrive + } It 'Should not throw an exception' { $testParameters = @{ - Drive = $testDrive - Type = 'SystemManagedSize' - Verbose = $true + Drive = $testDrive + Type = 'SystemManagedSize' + Verbose = $true } { Set-TargetResource @testParameters } | Should -Not -Throw @@ -500,8 +505,8 @@ try { Assert-MockCalled ` -CommandName Set-PageFileSetting ` -ParameterFilter { - $Drive -eq $testDrive - } ` + $Drive -eq $testDrive + } ` -Exactly -Times 1 } } @@ -529,14 +534,14 @@ try { Mock ` -CommandName Set-PageFileSetting ` -ParameterFilter { - $Drive -eq $testDrive - } + $Drive -eq $testDrive + } It 'Should not throw an exception' { $testParameters = @{ - Drive = $testDrive - Type = 'SystemManagedSize' - Verbose = $true + Drive = $testDrive + Type = 'SystemManagedSize' + Verbose = $true } { Set-TargetResource @testParameters } | Should -Not -Throw @@ -566,8 +571,8 @@ try { Assert-MockCalled ` -CommandName Set-PageFileSetting ` -ParameterFilter { - $Drive -eq $testDrive - } ` + $Drive -eq $testDrive + } ` -Exactly -Times 1 } } @@ -592,9 +597,9 @@ try { It 'Should not throw an exception' { $testParameters = @{ - Drive = $testDrive - Type = 'NoPagingFile' - Verbose = $true + Drive = $testDrive + Type = 'NoPagingFile' + Verbose = $true } { Set-TargetResource @testParameters } | Should -Not -Throw @@ -643,9 +648,9 @@ try { It 'Should not throw an exception' { $testParameters = @{ - Drive = $testDrive - Type = 'NoPagingFile' - Verbose = $true + Drive = $testDrive + Type = 'NoPagingFile' + Verbose = $true } { Set-TargetResource @testParameters } | Should -Not -Throw @@ -750,12 +755,12 @@ try { -CommandName Get-PageFileSetting ` -ParameterFilter $parameterFilterGetPageFileSetting ` -MockWith { - [PSObject] @{ - InitialSize = 0 - MaximumSize = 0 - Name = "$testDrive\" - } + [PSObject] @{ + InitialSize = 0 + MaximumSize = 0 + Name = "$testDrive\" } + } It 'Should return true' { $testParameters = @{ @@ -793,12 +798,12 @@ try { -CommandName Get-PageFileSetting ` -ParameterFilter $parameterFilterGetPageFileSetting ` -MockWith { - [PSObject] @{ - InitialSize = $testInitialSize - MaximumSize = $testMaximumSize - Name = "$testDrive\" - } + [PSObject] @{ + InitialSize = $testInitialSize + MaximumSize = $testMaximumSize + Name = "$testDrive\" } + } It 'Should return true' { $testParameters = @{ @@ -865,12 +870,12 @@ try { -CommandName Get-PageFileSetting ` -ParameterFilter $parameterFilterGetPageFileSetting ` -MockWith { - [PSObject] @{ - InitialSize = $testInitialSize - MaximumSize = $testMaximumSize - Name = "$testDrive\" - } + [PSObject] @{ + InitialSize = $testInitialSize + MaximumSize = $testMaximumSize + Name = "$testDrive\" } + } It 'Should return false' { $testParameters = @{ @@ -908,12 +913,12 @@ try { -CommandName Get-PageFileSetting ` -ParameterFilter $parameterFilterGetPageFileSetting ` -MockWith { - [PSObject] @{ - InitialSize = $testInitialSize - MaximumSize = $testMaximumSize - Name = "$testDrive\" - } + [PSObject] @{ + InitialSize = $testInitialSize + MaximumSize = $testMaximumSize + Name = "$testDrive\" } + } It 'Should return false' { $testParameters = @{ @@ -951,12 +956,12 @@ try { -CommandName Get-PageFileSetting ` -ParameterFilter $parameterFilterGetPageFileSetting ` -MockWith { - [PSObject] @{ - InitialSize = $testInitialSize - MaximumSize = $testMaximumSize - Name = "$testDrive\" - } + [PSObject] @{ + InitialSize = $testInitialSize + MaximumSize = $testMaximumSize + Name = "$testDrive\" } + } It 'Should return false' { $testParameters = @{ @@ -994,12 +999,12 @@ try { -CommandName Get-PageFileSetting ` -ParameterFilter $parameterFilterGetPageFileSetting ` -MockWith { - [PSObject] @{ - InitialSize = $testInitialSize - MaximumSize = $testMaximumSize - Name = "$testDrive\" - } + [PSObject] @{ + InitialSize = $testInitialSize + MaximumSize = $testMaximumSize + Name = "$testDrive\" } + } It 'Should return false' { $testParameters = @{ @@ -1034,12 +1039,12 @@ try { -CommandName Get-CimInstance ` -ParameterFilter $parameterFilterPageFileSetting ` -MockWith { - [PSObject] @{ - InitialSize = $testInitialSize - MaximumSize = $testMaximumSize - Name = "$testDrive\" - } + [PSObject] @{ + InitialSize = $testInitialSize + MaximumSize = $testMaximumSize + Name = "$testDrive\" } + } It 'Should return the expected object' { $result = Get-PageFileSetting -Drive $testDrive -Verbose @@ -1070,7 +1075,7 @@ try { -InitialSize $testInitialSize ` -MaximumSize $testMaximumSize ` -Verbose - } | Should -Not -Throw + } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -1139,6 +1144,7 @@ try { } } } -finally { +finally +{ Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_WindowsEventLog.Tests.ps1 b/Tests/Unit/MSFT_WindowsEventLog.Tests.ps1 index 0a682847..30eb6ccb 100644 --- a/Tests/Unit/MSFT_WindowsEventLog.Tests.ps1 +++ b/Tests/Unit/MSFT_WindowsEventLog.Tests.ps1 @@ -1,32 +1,33 @@ #region HEADER -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_WindowsEventLog' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'MSFT_WindowsEventLog' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global -# Unit Test Template Version: 1.2.0 -$script:moduleRoot = Join-Path -Path $(Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path))) -ChildPath 'Modules\ComputerManagementDsc' +# Unit Test Template Version: 1.2.4 +$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force $TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` -TestType Unit #endregion HEADER # Begin Testing try { - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'MSFT_WindowsEventLog' + InModuleScope $script:dscResourceName { + $script:dscResourceName = 'MSFT_WindowsEventLog' - Describe "$($script:DSCResourceName)\Get-TargetResource" -Tag 'Get' { + Describe "$($script:dscResourceName)\Get-TargetResource" -Tag 'Get' { Mock -CommandName Get-WindowsEventLog -MockWith { $properties = @{ @@ -77,7 +78,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" -Tag 'Test' { + Describe "$($script:dscResourceName)\Test-TargetResource" -Tag 'Test' { Mock -CommandName Get-WindowsEventLog -MockWith { $properties = @{ @@ -245,7 +246,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" -Tag 'Set' { + Describe "$($script:dscResourceName)\Set-TargetResource" -Tag 'Set' { Mock -CommandName Get-WindowsEventLog -MockWith { $properties = @{ MaximumSizeInBytes = 5000kb @@ -366,17 +367,17 @@ try Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It } - Describe "$($script:DSCResourceName)\Save-LogFile" -Tag 'Helper' { + Describe "$($script:dscResourceName)\Save-LogFile" -Tag 'Helper' { Mock -CommandName Limit-Eventlog -MockWith { throw } - + It 'Should throw if we are unable to get a log' { { Limit-Eventlog -LogName 'Application' -OverflowAction 'OverwriteOlder' -RetentionDays 30 } | Should -Throw } } - Describe "$($script:DSCResourceName)\Set-LogRetentionDays" -Tag 'Helper' { + Describe "$($script:dscResourceName)\Set-LogRetentionDays" -Tag 'Helper' { Mock -CommandName Limit-Eventlog -MockWith { throw } - + It 'Should throw if we are unable to get a log' { { Limit-Eventlog -LogName 'Application' -OverflowAction 'OverwriteOlder' -RetentionDays 30 } | Should -Throw } diff --git a/appveyor.yml b/appveyor.yml index 1ab4075a..84c8d717 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,12 +2,14 @@ # environment configuration # #---------------------------------# version: 1.9.{build}.0 +environment: + gallery_api: + secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv install: - git clone https://github.com/PowerShell/DscResource.Tests - ps: | $moduleName = 'ComputerManagementDsc' - $mainModuleFolder = "Modules\$moduleName" Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" Invoke-AppveyorInstallTask @@ -24,10 +26,9 @@ build: false test_script: - ps: | Invoke-AppveyorTestScriptTask ` - -Type 'Harness' ` - -MainModulePath $mainModuleFolder ` -CodeCoverage ` - -CodeCovIo + -CodeCovIo ` + -ExcludeTag @() #---------------------------------# # deployment configuration # @@ -38,5 +39,6 @@ deploy_script: - ps: | Invoke-AppveyorAfterTestTask ` -Type 'Wiki' ` - -MainModulePath $mainModuleFolder ` -ResourceModuleName $moduleName + + Invoke-AppVeyorDeployTask