added changes from code review testing credentials
This commit is contained in:
parent
e76abe2416
commit
e19b2fab4b
1 changed files with 43 additions and 15 deletions
|
@ -1,23 +1,33 @@
|
|||
Describe "Test-New-Item" {
|
||||
$tmpDirectory = "/tmp"
|
||||
$testfile = "testfile.txt"
|
||||
$testfolder = "newDirectory"
|
||||
|
||||
$FullyQualifiedFile = $tmpDirectory + "/" + $testfile
|
||||
$FullyQualifiedFolder = $tmpDirectory +"/" + $testfolder
|
||||
|
||||
AfterEach {
|
||||
function Clean-State
|
||||
{
|
||||
if (Test-Path $FullyQualifiedFile)
|
||||
{
|
||||
{ Remove-Item $FullyQualifiedFile -Force} | Should Not Throw
|
||||
Remove-Item $FullyQualifiedFile -Force
|
||||
}
|
||||
|
||||
if (Test-Path $FullyQualifiedFolder)
|
||||
{
|
||||
{ Remove-Item $FullyQualifiedFolder -Recurse -Force } | Should Not Throw
|
||||
Remove-Item $FullyQualifiedFolder -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Test-New-Item" {
|
||||
$tmpDirectory = "/tmp"
|
||||
$testfile = "testfile.txt"
|
||||
$testfolder = "newDirectory"
|
||||
$FullyQualifiedFile = $tmpDirectory + "/" + $testfile
|
||||
$FullyQualifiedFolder = $tmpDirectory + "/" + $testfolder
|
||||
|
||||
BeforeEach {
|
||||
Clean-State
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
Clean-State
|
||||
Test-Path $FullyQualifiedFile | Should Be $false
|
||||
Test-Path $FullyQualifiedFolder | Should Be $false
|
||||
}
|
||||
|
||||
It "should call the function without error" {
|
||||
{ New-Item -Name $testfile -Path $tmpDirectory -ItemType file } | Should Not Throw
|
||||
}
|
||||
|
@ -78,4 +88,22 @@
|
|||
|
||||
Remove-Item $FullyQualifiedFile2
|
||||
}
|
||||
|
||||
It "Should be able to call the whatif switch without error" {
|
||||
( Out-Null -inputobject (New-Item -Name testfile.txt -Path /tmp -ItemType file -WhatIf))
|
||||
{ $a } | Should Not Throw
|
||||
}
|
||||
|
||||
It "Should not create a new file when the whatif switch is used" {
|
||||
# suppress the output of the whatif statement
|
||||
$a = New-Item -Name $testfile -Path $tmpDirectory -ItemType file -WhatIf
|
||||
|
||||
Out-Null -inputobject $a
|
||||
|
||||
Test-Path $FullyQualifiedFile | Should Be $false
|
||||
}
|
||||
|
||||
It "Should produce an error when the credentials switch is thrown" {
|
||||
{ New-Item -Name $testfile -Path $tmpDirectory -ItemType file -Credential redmond/USER } | Should Throw "not implemented"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue