Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated tests to meet Pester V4 guidelines - Fixes #106 #129

Merged
merged 2 commits into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ xVirtualMemory has the following properties:
* Updated to meet HQRM guidelines.
* xComputer:
* Resolved bug in Get-ComputerDomain where LocalSystem doesn't have
rights to the domain
rights to the domain.
* Updated tests to meet Pester V4 guidelines - See [Issue #106](https://github.com/PowerShell/xComputerManagement/issues/106).

### 3.2.0.0

Expand Down
52 changes: 26 additions & 26 deletions Tests/Integration/MSFT_xScheduledTask.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ try
. $currentConfig `
-OutputPath $configDir `
-ConfigurationData $configData
} | Should Not Throw
} | Should -Not -Throw
}

It 'Should apply the MOF correctly' {
Expand All @@ -70,11 +70,11 @@ try
-Force `
-Verbose `
-ErrorAction Stop
} | Should Not Throw
} | Should -Not -Throw
}

It 'Should return a compliant state after being applied' {
(Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should be $true
(Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -Be $true
}
}

Expand All @@ -88,7 +88,7 @@ try
. $currentConfig `
-OutputPath $configDir `
-ConfigurationData $configData
} | Should Not Throw
} | Should -Not -Throw
}

It 'Should apply the MOF correctly' {
Expand All @@ -99,11 +99,11 @@ try
-Force `
-Verbose `
-ErrorAction Stop
} | Should Not Throw
} | Should -Not -Throw
}

It 'Should return a compliant state after being applied' {
(Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should be $true
(Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -Be $true
}
}

Expand All @@ -117,7 +117,7 @@ try
. $currentConfig `
-OutputPath $configDir `
-ConfigurationData $configData
} | Should Not Throw
} | Should -Not -Throw
}

It 'Should apply the MOF correctly' {
Expand All @@ -128,11 +128,11 @@ try
-Force `
-Verbose `
-ErrorAction Stop
} | Should Not Throw
} | Should -Not -Throw
}

It 'Should return a compliant state after being applied' {
(Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should be $true
(Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -Be $true
}
}
}
Expand All @@ -152,7 +152,7 @@ try
Set-TimeZoneId -Id 'W. Australia Standard Time'
. $currentConfig `
-OutputPath $configDir
} | Should Not Throw
} | Should -Not -Throw
}

It 'Should apply the MOF correctly in New Zealand Standard Time Timezone' {
Expand All @@ -164,29 +164,29 @@ try
-Force `
-Verbose `
-ErrorAction Stop
} | Should Not Throw
} | Should -Not -Throw
}

It 'Should return a compliant state after being applied' {
(Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should be $true
(Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -Be $true
}

It 'Should have set the resource and all the parameters should match' {
$current = Get-DscConfiguration | Where-Object {$_.ConfigurationName -eq $currentConfig}
$current.TaskName | Should Be 'Test task once cross timezone'
$current.TaskPath | Should Be '\xComputerManagement\'
$current.ActionExecutable | Should Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
$current.ScheduleType | Should Be 'Once'
$current.RepeatInterval | Should Be '00:15:00'
$current.RepetitionDuration | Should Be '23:00:00'
$current.ActionWorkingPath | Should Be (Get-Location).Path
$current.Enable | Should Be $true
$current.RandomDelay | Should Be '01:00:00'
$current.DisallowHardTerminate | Should Be $true
$current.RunOnlyIfIdle | Should Be $false
$current.Priority | Should Be 9
$current.RunLevel | Should Be 'Limited'
$current.ExecutionTimeLimit | Should Be '00:00:00'
$current.TaskName | Should -Be 'Test task once cross timezone'
$current.TaskPath | Should -Be '\xComputerManagement\'
$current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
$current.ScheduleType | Should -Be 'Once'
$current.RepeatInterval | Should -Be '00:15:00'
$current.RepetitionDuration | Should -Be '23:00:00'
$current.ActionWorkingPath | Should -Be (Get-Location).Path
$current.Enable | Should -Be $true
$current.RandomDelay | Should -Be '01:00:00'
$current.DisallowHardTerminate | Should -Be $true
$current.RunOnlyIfIdle | Should -Be $false
$current.Priority | Should -Be 9
$current.RunLevel | Should -Be 'Limited'
$current.ExecutionTimeLimit | Should -Be '00:00:00'
}

AfterAll {
Expand Down
54 changes: 27 additions & 27 deletions Tests/Integration/MSFT_xVirtualMemory.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$script:DSCModuleName = 'xComputerManagement'
$script:DSCResourceName = 'MSFT_xVirtualMemory'
$script:DSCModuleName = 'xComputerManagement'
$script:DSCResourceName = 'MSFT_xVirtualMemory'

#region HEADER
# Integration Test Template Version: 1.1.1
Expand All @@ -26,92 +26,92 @@ try
. $configFile

Describe "$($script:DSCResourceName)_Integration" {

Context "Set page file to automatically managed" {
$CurrentConfig = "setToAuto"
$ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig)
$ConfigMof = (Join-Path -Path $ConfigDir -ChildPath "localhost.mof")

It "should compile a MOF file without error" {
{
. $CurrentConfig -OutputPath $ConfigDir
} | Should Not Throw
} | Should -Not -Throw
}

It "should apply the MOF correctly" {
{
Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force
} | Should Not Throw
} | Should -Not -Throw
}

It "should return a compliant state after being applied" {
(Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should be $true
(Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true
}
}

Context "Set page file to custom size" {
$CurrentConfig = "setToCustom"
$ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig)
$ConfigMof = (Join-Path -Path $ConfigDir -ChildPath "localhost.mof")

It "should compile a MOF file without error" {
{
. $CurrentConfig -OutputPath $ConfigDir
} | Should Not Throw
} | Should -Not -Throw
}

It "should apply the MOF correctly" {
{
Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force
} | Should Not Throw
} | Should -Not -Throw
}

It "should return a compliant state after being applied" {
(Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should be $true
(Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true
}
}

Context "Set page file to system managed" {
$CurrentConfig = "setToSystemManaged"
$ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig)
$ConfigMof = (Join-Path -Path $ConfigDir -ChildPath "localhost.mof")

It "should compile a MOF file without error" {
{
. $CurrentConfig -OutputPath $ConfigDir
} | Should Not Throw
} | Should -Not -Throw
}

It "should apply the MOF correctly" {
{
Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force
} | Should Not Throw
} | Should -Not -Throw
}

It "should return a compliant state after being applied" {
(Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should be $true
(Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true
}
}

Context "Set page file to none" {
$CurrentConfig = "setToNone"
$ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig)
$ConfigMof = (Join-Path -Path $ConfigDir -ChildPath "localhost.mof")

It "should compile a MOF file without error" {
{
. $CurrentConfig -OutputPath $ConfigDir
} | Should Not Throw
} | Should -Not -Throw
}

It "should apply the MOF correctly" {
{
Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force
} | Should Not Throw
} | Should -Not -Throw
}

It "should return a compliant state after being applied" {
(Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should be $true
(Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true
}
}
}
Expand Down
Loading