Skip to content

Commit

Permalink
Fixes SiteName beeing required (#126)
Browse files Browse the repository at this point in the history
* Adds unit test for this scenario
* Add chack if sitename was specified or not
* Fixes #119
  • Loading branch information
gordonbondon authored and TravisEz13 committed Nov 30, 2016
1 parent 4e3d5f4 commit 23b18b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function Set-TargetResource
elseif ($targetResource.Ensure)
{
## Node is a domain controller. We check if other properties are in desired state
if ($targetResource.SiteName -ne $SiteName)
if ($PSBoundParameters["SiteName"] -and $targetResource.SiteName -ne $SiteName)
{
## DC is not in correct site. Move it.
Write-Verbose "Moving Domain Controller from '$($targetResource.SiteName)' to '$SiteName'"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ Setting an ODJ Request file path for a configuration that creates a computer acc
## Versions

### Unreleased
* xAdDomainController: Fixes SiteName being required field.

### 2.14.0.0
* xADDomainController: Adds Site option.
Expand Down
15 changes: 15 additions & 0 deletions Tests/Unit/MSFT_xADDomainController.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,21 @@ try

Assert-MockCalled Move-ADDirectoryServer -Times 0 @commonAssertParams
}

It 'Does not call "Move-ADDirectoryServer" when "SiteName" is not specified' {
Mock Get-TargetResource {
return $stubTargetResource = @{
Ensure = $true
SiteName = 'PresentSite'
}
} @commonMockParams

Mock Move-ADDirectoryServer {} @commonMockParams

Set-TargetResource @testDefaultParams -DomainName $correctDomainName

Assert-MockCalled Move-ADDirectoryServer -Times 0 @commonAssertParams
}
}
#endregion
}
Expand Down

0 comments on commit 23b18b1

Please sign in to comment.