-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(tests): add Get-HubberReports and Get-Reports functions #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
| $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 warningCode scanning / PSScriptAnalyzer The variable 'result' is assigned but never used. Warning
The variable 'result' is assigned but never used.
|
||
|
|
||
| # Act & Assert | ||
| Assert-NotImplemented | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| function Get-HubberReports { | ||
Check warningCode 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 noticeCode 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 warningCode 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 warningCode 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 warningCode 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 | ||
| } | ||
| } | ||
Check warning
Code scanning / PSScriptAnalyzer
The variable 'result' is assigned but never used. Warning