Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Test/public/gethubberreports.test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

function Test_GetHubberReports_Success_All{

# Arrange
Reset-InvokeCommandMock
Mock_Database
$filePath = Get-MockFileFullPath -fileName "hubbers.json"
$result = Import-HubbersListV2 -Path $filePath

Check warning

Code scanning / PSScriptAnalyzer

The variable 'result' is assigned but never used. Warning

The variable 'result' is assigned but never used.

$l = Get-HubbersList

foreach($h in $l.Keys){

# Act
$r = Get-HubberReports -Handle $h

# Assert
Assert-Count -Expected ($l.$h.totalReports) -Presented $r
}
}

function Test_GetHubberReports_HubberNotFound{

# Arrange
Reset-InvokeCommandMock
Mock_Database
$filePath = Get-MockFileFullPath -fileName "hubbers.json"
$result = Import-HubbersList -Path $filePath

Check warning

Code scanning / PSScriptAnalyzer

The variable 'result' is assigned but never used. Warning

The variable 'result' is assigned but never used.

# Act & Assert
Assert-NotImplemented
}
38 changes: 38 additions & 0 deletions public/getHubberReports.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function Get-HubberReports {

Check warning

Code scanning / PSScriptAnalyzer

The cmdlet 'Get-HubberReports' uses a plural noun. A singular noun should be used instead. Warning

The cmdlet 'Get-HubberReports' uses a plural noun. A singular noun should be used instead.

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Get-HubberReports' does not have a help comment. Note

The cmdlet 'Get-HubberReports' does not have a help comment.
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName,Position=0)][string]$Handle

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.
)

$node = Get-Hubber -Handle $Handle

if($null -eq $node){
throw "Hubber with handle '$Handle' not found"
}

# recurse for every report
$ret = $node.reports.values | Get-Reports

return $ret

} Export-ModuleMember -Function Get-HubberReports

function Get-Reports{

Check warning

Code scanning / PSScriptAnalyzer

The cmdlet 'Get-Reports' uses a plural noun. A singular noun should be used instead. Warning

The cmdlet 'Get-Reports' uses a plural noun. A singular noun should be used instead.
param (
[Parameter(ValueFromPipeline)][object]$node
)
process{

if($null -eq $node){
return @()
}

$ret = @()

$ret = $node.reports.values | Get-Reports

$ret += $node

return $ret
}
}
Loading