Skip to content

Commit

Permalink
Merge pull request #58 from PowerShell/dev
Browse files Browse the repository at this point in the history
Merging release pull request
  • Loading branch information
kwirkykat authored Aug 10, 2016
2 parents 6cdaca1 + 22225f0 commit 7e557ba
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DSCResources/MSFT_xVMHyperV/MSFT_xVMHyperV.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,10 @@ function Get-VhdHierarchy
[Parameter(Mandatory)]
[System.String] $VhdPath
)

$vmVhdPath = Get-VHD -Path $VhdPath
Write-Output -InputObject $vmVhdPath.Path
while($vmVhdPath.ParentPath -ne [String]::Empty)
while(-not [System.String]::IsNullOrEmpty($vmVhdPath.ParentPath))
{
$vmVhdPath.ParentPath
$vmVhdPath = (Get-VHD -Path $vmVhdPath.ParentPath)
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

The **xHyper-V** DSC module configures and manages a Hyper-V host using the **xVhd**, **xVMHyperV**, **xVMSwitch**, **xVhdFileDirectory** resources.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Contributing
Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md).

Expand Down Expand Up @@ -75,6 +78,11 @@ Please see the Examples section for more details.

### Unreleased

### 3.5.0.0
* Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey.

* MSFT_xVMHyperV: Fixed bug in Test-TargetResource throwing when a Vhd's ParentPath property was null.

### 3.4.0.0

* MSFT_xVMHyperV: Fixed bug causing Test-TargetResource to fail when VM had snapshots.
Expand Down
21 changes: 21 additions & 0 deletions Tests/MSFT_xVMHyper-V/xVMHyper-V.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Describe 'xVMHyper-V' {
function Get-VMIntegrationService { param ([Parameter(ValueFromPipeline)] $VM, $Name)}
function Enable-VMIntegrationService { param ([Parameter(ValueFromPipeline)] $VM, $Name)}
function Disable-VMIntegrationService { param ([Parameter(ValueFromPipeline)] $VM, $name)}
function Get-VHD { param ( $Path ) }

$stubVhdxDisk = New-Item -Path 'TestDrive:\TestVM.vhdx' -ItemType File;
$studVhdxDiskSnapshot = New-Item -Path "TestDrive:\TestVM_D0145678-1576-4435-AB18-9F000C1C17D0.avhdx" -ItemType File;
Expand Down Expand Up @@ -97,6 +98,7 @@ Describe 'xVMHyper-V' {
}
Mock -CommandName Get-VMIntegrationService -MockWith {return [pscustomobject]@{Enabled=$false}}
Mock -CommandName Get-Module -ParameterFilter { ($Name -eq 'Hyper-V') -and ($ListAvailable -eq $true) } -MockWith { return $true; }

Mock -CommandName Get-VhdHierarchy -ParameterFilter { $VhdPath.EndsWith('.vhd') } -MockWith {
## Return single Vhd chain for .vhds
return @($stubVhdDisk.FullName);
Expand Down Expand Up @@ -480,5 +482,24 @@ Describe 'xVMHyper-V' {
}
} #end context Validates Change-VMSecureBoot Method

Context 'Validates Get-VhdHierarchy Method' {

It 'Does not throw with null parent path (#52)' {

## Must use a different file extension to ensure existing mocks Get-VhdHierarchy or not called
$fakeVhdPath = 'BaseVhd.avhdx';
Mock -CommandName Get-VHD -ParameterFilter { $Path -eq $fakeVhdPath } -MockWith {
return [PSCustomObject] @{
Path = $fakeVhdPath;
ParentPath = $null;
}
}

{ Get-VhdHierarchy -VhdPath $fakeVhdPath } | Should Not Throw;
}

} #end context validates Get-VhdHierarchy


} #end inmodulescope
} #end describe xVMHyper-V
15 changes: 7 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#---------------------------------#
# environment configuration #
#---------------------------------#
version: 3.4.{build}.0
version: 3.5.{build}.0
install:
- cinst -y pester
- git clone https://github.com/PowerShell/DscResource.Tests
- ps: Push-Location
- cd DscResource.Tests
- ps: Import-Module .\TestHelper.psm1 -force
- ps: Pop-Location
- git clone https://github.com/PowerShell/DscResource.Tests
- ps: |
Import-Module -Name .\DscResource.Tests\TestHelper.psm1 -Force
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name Pester -Repository PSGallery -Force
#---------------------------------#
# build configuration #
Expand Down Expand Up @@ -39,7 +38,7 @@ deploy_script:
# Creating project artifact
$stagingDirectory = (Resolve-Path ..).Path
$manifest = Join-Path $pwd "xHyper-V.psd1"
(Get-Content $manifest -Raw).Replace("3.4.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest
(Get-Content $manifest -Raw).Replace("3.5.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest
$zipFilePath = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip"
Add-Type -assemblyname System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory($pwd, $zipFilePath)
Expand Down
9 changes: 7 additions & 2 deletions xHyper-V.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
# Version number of this module.
ModuleVersion = '3.4.0.0'
ModuleVersion = '3.5.0.0'

# ID used to uniquely identify this module
GUID = 'f5a5f169-7026-4053-932a-19a7c37b1ca5'
Expand Down Expand Up @@ -47,7 +47,11 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''
ReleaseNotes = '* Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey.
* MSFT_xVMHyperV: Fixed bug in Test-TargetResource throwing when a Vhd"s ParentPath property was null.
'

} # End of PSData hashtable

Expand All @@ -56,3 +60,4 @@ PrivateData = @{




0 comments on commit 7e557ba

Please sign in to comment.