Sha256: 4a951da3040262065a54d396209672ef9409f67eb1485498cec2cff5362d9c08

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

. $PSScriptRoot\..\..\support\hyperv.ps1

describe 'New-DifferencingDisk' {
  mock new-vhd -Verifiable -MockWith {}

  context 'mandatory parameters' {
    mock Test-Path -MockWith {}

    $command = get-command new-differencingDisk

    it 'Path is mandatory' {
      $Command.Parameters['Path'].Attributes.Mandatory | should be $true
    }
    it 'ParentPath is mandatory' {
      $Command.Parameters['ParentPath'].Attributes.Mandatory | should be $true
    }
  }

  context 'when differencing disk exists' {
    mock Test-Path -ParameterFilter {$Path -eq 'c:\.kitchen\diff.vhd'} -MockWith {$true}

    new-differencingDisk -Path 'c:\.kitchen\diff.vhd' -parentpath 'c:\source.vhd'

    it 'does not create a new vhd' {
      Assert-MockCalled new-vhd -Times 0
    }
  }

  context 'when a differencing disk does not exist' {
    mock Test-Path -ParameterFilter {$Path -eq 'c:\.kitchen\diff.vhd'} -MockWith {$false}

    new-differencingDisk -Path 'c:\.kitchen\diff.vhd' -parentpath 'c:\source.vhd'

    it 'creates a new differencing disk' {
      Assert-MockCalled new-vhd -Times 1 -ParameterFilter {
        $Path -eq 'c:\.kitchen\diff.vhd' -and 
        $ParentPath -eq 'c:\source.vhd' -and 
        $Differencing -eq $true
      }
    }
  }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kitchen-hyperv-0.2.3 spec/support/hyperv.Tests.ps1
kitchen-hyperv-0.2.1 spec/support/hyperv.Tests.ps1
kitchen-hyperv-0.2.0 spec/support/hyperv.Tests.ps1