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
Describe "$($Global:DSCResourceName)\Get-VirtualDisk" { | |
Context 'Virtual Disk does not exist' { | |
Mock Get-iSCSIVirtualDisk | |
It 'should return null' { | |
$Splat = $TestVirtualDisk.Clone() | |
$Result = Get-VirtualDisk -Path $Splat.Path | |
$Result | Should Be $null |
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
Context 'Virtual Disk exists and should but has a different ParentPath' { | |
Mock Get-iSCSIVirtualDisk -MockWith { return @($MockVirtualDisk) } | |
It 'should throw an exception' { | |
{ Test-TargetResource @Splat } | Should Throw | |
} | |
It 'should call expected Mocks' { | |
Assert-MockCalled -commandName Get-iSCSIVirtualDisk -Exactly 1 | |
} |
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
$errorId = 'iSCSIVirtualDiskRequiresRecreateError' | |
$errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument | |
$errorMessage = $($LocalizedData.iSCSIVirtualDiskRequiresRecreateError) -f $Path | |
$exception = New-Object -TypeName System.InvalidOperationException ` | |
-ArgumentList $errorMessage | |
$errorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord ` | |
-ArgumentList $exception, $errorId, $errorCategory, $null | |
$PSCmdlet.ThrowTerminatingError($errorRecord) |
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
Context 'Virtual Disk exists and should but has a different ParentPath' { | |
Mock Get-iSCSIVirtualDisk -MockWith { return @($MockVirtualDisk) } | |
It 'should throw an iSCSIVirtualDiskRequiresRecreateError exception' { | |
$Splat = $TestVirtualDisk.Clone() | |
$Splat.ParentPath = 'c:\NewParent.vhdx' | |
$errorId = 'iSCSIVirtualDiskRequiresRecreateError' | |
$errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument |
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
Remove-IscsiTargetPortal -TargetPortalAddress 192.168.129.24 |
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
Remove-IscsiTargetPortal -TargetPortalAddress 192.168.129.24 -InitiatorPortalAddress 192.168.129.30 |
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
git clone https://github.com/PowerShell/DSCResources.git | |
Copy-Item .\DSCResources\Tests.Template\integration_config_template.ps1 .\ciSCSI\Tests\Integration\BMD_ciSCSIVirtualDisk.config.ps1 | |
Copy-Item .\DSCResources\Tests.Template\integration_template.ps1 .\ciSCSI\Tests\Integration\BMD_ciSCSIVirtualDisk.Integration.Tests.ps1 |
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
configuration 'BMD_ciSCSIVirtualDisk_config' { | |
Import-DscResource -Name 'BMD_ciSCSIVirtualDisk' | |
node localhost { | |
BMD_ciSCSIVirtualDisk Integration_Test { | |
# TODO: Fill Configuration Code Here | |
} | |
} | |
} |
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
$VirtualDisk = @{ | |
Path = Join-Path -Path $ENV:Temp -ChildPath 'TestiSCSIVirtualDisk.vhdx' | |
Ensure = 'Present' | |
DiskType = 'Dynamic' | |
Size = 100MB | |
Description = 'Integration Test iSCSI Virtual Disk' | |
} | |
Configuration BMD_ciSCSIVirtualDisk_Config { | |
Import-DscResource -Name BMD_ciSCSIVirtualDisk_Config |
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
# Ensure that the tests can be performed on this computer | |
$ProductType = (Get-CimInstance Win32_OperatingSystem).ProductType | |
Describe 'Environment' { | |
Context 'Operating System' { | |
It 'Should be a Server OS' { | |
$ProductType | Should Be 3 | |
} | |
} | |
} | |
if ($ProductType -ne 3) |