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,21 +1,31 @@
|
||||||
Describe "Test-New-Item" {
|
function Clean-State
|
||||||
$tmpDirectory = "/tmp"
|
{
|
||||||
$testfile = "testfile.txt"
|
if (Test-Path $FullyQualifiedFile)
|
||||||
$testfolder = "newDirectory"
|
{
|
||||||
|
Remove-Item $FullyQualifiedFile -Force
|
||||||
|
}
|
||||||
|
|
||||||
$FullyQualifiedFile = $tmpDirectory + "/" + $testfile
|
if (Test-Path $FullyQualifiedFolder)
|
||||||
$FullyQualifiedFolder = $tmpDirectory +"/" + $testfolder
|
{
|
||||||
|
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 {
|
AfterEach {
|
||||||
if (Test-Path $FullyQualifiedFile)
|
Clean-State
|
||||||
{
|
Test-Path $FullyQualifiedFile | Should Be $false
|
||||||
{ Remove-Item $FullyQualifiedFile -Force} | Should Not Throw
|
Test-Path $FullyQualifiedFolder | Should Be $false
|
||||||
}
|
|
||||||
|
|
||||||
if (Test-Path $FullyQualifiedFolder)
|
|
||||||
{
|
|
||||||
{ Remove-Item $FullyQualifiedFolder -Recurse -Force } | Should Not Throw
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
It "should call the function without error" {
|
It "should call the function without error" {
|
||||||
|
@ -78,4 +88,22 @@
|
||||||
|
|
||||||
Remove-Item $FullyQualifiedFile2
|
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