Skip to content

Commit

Permalink
improvements to Get-WikiChildPage
Browse files Browse the repository at this point in the history
implements AtlassianPS#15
  • Loading branch information
lipkau committed Apr 15, 2017
1 parent 6279649 commit 7513f22
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
15 changes: 7 additions & 8 deletions ConfluencePS/Public/Get-WikiChildPage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,13 @@
Position = 0,
Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = "byID"
)]
[ValidateRange(1, [int]::MaxValue)]
[Alias('ID')]
[int]$PageID,

# Find child pages by Page Object
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true,
ParameterSetName = "byObject"
)]
[ConfluencePS.Page]$InputObject,

# Get all child pages recursively
[switch]$Recurse,

Expand All @@ -76,6 +69,12 @@
Write-Debug "ParameterSetName: $($PsCmdlet.ParameterSetName)"
Write-Debug "PSBoundParameters: $($PSBoundParameters | Out-String)"

if (($_) -and -not($_ -is [ConfluencePS.Page] -or $_ -is [int])) {
$message = "The Object in the pipe is not a Page."
$exception = New-Object -TypeName System.ArgumentException -ArgumentList $message
Throw $exception
}

if ($PsCmdlet.ParameterSetName -eq "byObject") {
$PageID = $InputObject.ID
}
Expand Down
20 changes: 19 additions & 1 deletion Tests/ConfluencePS.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,25 @@ InModuleScope ConfluencePS {
}
}

Describe 'Remove-WikiLabel' {
Describe 'Get-WikiChildPage' {
# ARRANGE

# ACT
$ChildPages = (Get-WikiSpace -SpaceKey PESTER).Homepage | Get-WikiChildPage
$DesendantPages = (Get-WikiSpace -SpaceKey PESTER).Homepage | Get-WikiChildPage -Recurse

# ASSERT
It 'returns the correct amount of results' {
$ChildPages.Count | Should Be 2
$DesendantPages.Count | Should Be 4
}
It 'returns an object with specific properties' {
$ChildPages | Should BeOfType [ConfluencePS.Page]
$DesendantPages | Should BeOfType [ConfluencePS.Page]
}
}

Describe 'Remove-WikiLabel' {
# ARRANGE
$Label1 = "pesterc"
$Page1 = Get-WikiPage -Title 'Pester New Page Piped' -ErrorAction Stop
Expand Down

0 comments on commit 7513f22

Please sign in to comment.