forked from PowerShell/DscResource.Tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test for helper function Start-DscResourceTests (PowerShel…
…l#182) * Added unit test Added unit test for helper function Start-DscResourceTests. * Changes to common tests - Updated AppVeyor code so that common tests and unit tests is run on the working branch's tests. This is to be able to test changes to tests in pull requests without having to merge the pull request before seeing the result. * Changes to common tests - Updated the logic to check for a module manifest instead of using APPVEYOR_BUILD_FOLDER environment variable.
- Loading branch information
Showing
4 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
$script:ModuleName = 'TestRunner' | ||
$script:moduleRootPath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent | ||
|
||
Describe "$($script:ModuleName) Unit Tests" { | ||
BeforeAll { | ||
Import-Module -Name (Join-Path -Path $script:moduleRootPath -ChildPath "$($script:ModuleName).psm1") -Force | ||
} | ||
|
||
InModuleScope $script:ModuleName { | ||
Describe 'Start-DscResourceTests' { | ||
BeforeAll { | ||
# Set up TestDrive | ||
$mockResourcePath = Join-Path -Path 'TestDrive:' -ChildPath 'DscResources' | ||
New-Item -Path $mockResourcePath -ItemType Directory | ||
|
||
$mockResource1Path = Join-Path -Path $mockResourcePath -ChildPath 'Resource1' | ||
New-Item -Path $mockResource1Path -ItemType Directory | ||
|
||
$mockResource2Path = Join-Path -Path $mockResourcePath -ChildPath 'Resource2' | ||
New-Item -Path $mockResource2Path -ItemType Directory | ||
|
||
Push-Location | ||
|
||
Set-Location -Path $mockResourcePath | ||
} | ||
|
||
BeforeEach { | ||
Mock -CommandName Push-Location -Verifiable | ||
Mock -CommandName Pop-Location -Verifiable | ||
Mock -CommandName Invoke-Pester -Verifiable | ||
} | ||
|
||
Context 'When starting tests' { | ||
It 'Should call Invoke-Pester exactly 2 times' { | ||
{ Start-DscResourceTests -ResourcesPath $mockResourcePath } | Should Not Throw | ||
|
||
Assert-MockCalled -CommandName Invoke-Pester -Exactly -Times 2 | ||
} | ||
} | ||
|
||
AfterAll { | ||
Pop-Location | ||
} | ||
|
||
Assert-VerifiableMocks | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters