Use $here to avoid 'cd $(PESTER)'
Per the Pester examples: https://github.com/pester/Pester/blob/master/Examples/Calculator/Add-Numbers.Tests.ps1
This commit is contained in:
parent
9b003f059c
commit
0b6adb68ee
2
Makefile
2
Makefile
|
@ -57,7 +57,7 @@ test-hashbang:
|
|||
## - we cd because some tests rely on the current working directory
|
||||
PESTER=$(MONAD)/src/pester-tests
|
||||
test-pester:
|
||||
$(POWERSHELL_SIMPLE) 'cd $(PESTER); $$env:TEMP="/tmp"; invoke-pester -OutputFile $(MONAD)/pester-tests.xml -OutputFormat NUnitXml'
|
||||
$(POWERSHELL_SIMPLE) '$$env:TEMP="/tmp"; invoke-pester $(PESTER) -OutputFile $(MONAD)/pester-tests.xml -OutputFormat NUnitXml'
|
||||
|
||||
## Pester self-tests
|
||||
## - results in pester-self-tests.xml
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
Describe "Get-Item" {
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
Describe "Get-Item" {
|
||||
It "Should list all the items in the current working directory when asterisk is used" {
|
||||
(Get-Item *).GetType().BaseType | Should Be 'array'
|
||||
(Get-Item *).GetType().Name | Should Be 'Object[]'
|
||||
(Get-Item $here/*).GetType().BaseType | Should Be 'array'
|
||||
(Get-Item $here/*).GetType().Name | Should Be 'Object[]'
|
||||
}
|
||||
|
||||
It "Should return the name of the current working directory when a dot is used" {
|
||||
(Get-Item .).GetType().BaseType | Should Be 'System.IO.FileSystemInfo'
|
||||
(Get-Item .).Name | Should Be 'pester-tests'
|
||||
(Get-Item $here).GetType().BaseType | Should Be 'System.IO.FileSystemInfo'
|
||||
(Get-Item $here).Name | Should Be 'pester-tests'
|
||||
}
|
||||
|
||||
It "Should return the proper Name and BaseType for directory objects vs file system objects" {
|
||||
(Get-Item .).GetType().Name | Should Be 'DirectoryInfo'
|
||||
(Get-Item ./Get-Item.Tests.ps1).GetType().Name | Should Be 'FileInfo'
|
||||
}
|
||||
|
||||
It "Should return a different directory when a path argument is used" {
|
||||
(Get-Item /usr/bin) | Should Not BeNullOrEmpty
|
||||
(Get-Item ..) | Should Not BeNullOrEmpty
|
||||
(Get-Item $here).GetType().Name | Should Be 'DirectoryInfo'
|
||||
(Get-Item $here/Get-Item.Tests.ps1).GetType().Name | Should Be 'FileInfo'
|
||||
}
|
||||
|
||||
It "Should have mode flags set" {
|
||||
ls / | foreach-object { $_.Mode | Should Not BeNullOrEmpty }
|
||||
ls $here | foreach-object { $_.Mode | Should Not BeNullOrEmpty }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
Describe "Get-ItemProperty" {
|
||||
$currentDirectory = Split-Path . -Leaf
|
||||
$parentDirectory = Split-Path .. -Leaf
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
Describe "Get-ItemProperty" {
|
||||
$currentDirectory = Split-Path $here -Leaf
|
||||
$parentDirectory = Split-Path $here/.. -Leaf
|
||||
if (Test-Path /tmp)
|
||||
{
|
||||
$tempDirectory = "/tmp/testfolder"
|
||||
|
@ -18,15 +20,11 @@
|
|||
New-Item $testfile -ItemType file -Force
|
||||
|
||||
It "Should be able to be called on in the current directory" {
|
||||
{ Get-ItemProperty . } | Should Not Throw
|
||||
|
||||
$(Get-ItemProperty .).Name | Should Be $currentDirectory
|
||||
$(Get-ItemProperty $here).Name | Should Be $currentDirectory
|
||||
}
|
||||
|
||||
It "Should be able to be called on a parent directory" {
|
||||
{ Get-ItemProperty .. } | Should Not Throw
|
||||
|
||||
(Get-ItemProperty ..).Name | Should Be $parentDirectory
|
||||
(Get-ItemProperty $here/..).Name | Should Be $parentDirectory
|
||||
}
|
||||
|
||||
It "Should be able to be called on a directory using the path switch" {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
Describe "Import-Csv" {
|
||||
$testCsv = "./assets/TestCsv.csv"
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
Describe "Import-Csv" {
|
||||
$testCsv = "$here/assets/TestCsv.csv"
|
||||
|
||||
It "Should be able to call without error" {
|
||||
{ Import-Csv $testCsv } | Should Not Throw
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
. ./Test-Mocks.ps1
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
. "$here/Test-Mocks.ps1"
|
||||
|
||||
Describe "Select-Object" {
|
||||
BeforeEach {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
Describe "Set-PSBreakpoint" {
|
||||
New-Variable -Name script -Value ./assets/testablescript.ps1 -Scope Global
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
|
||||
Describe "Set-PSBreakpoint" {
|
||||
New-Variable -Name script -Value $here/assets/testablescript.ps1 -Scope Global
|
||||
|
||||
It "Should be able to called with script and line parameters without error " {
|
||||
{ Set-PSBreakpoint -Script $script -Line 1 } | Should Not Throw
|
||||
|
|
Loading…
Reference in a new issue