Skip to content

Commit

Permalink
Remove-TssReportCategory - output changed to TssDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Feb 8, 2021
1 parent e2eaee1 commit c5adf0f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/functions/reports/Remove-ReportCategory.ps1
Expand Up @@ -27,7 +27,7 @@
Requires TssSession object returned by New-TssSession
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
[OutputType('Boolean')]
[OutputType('TssDelete')]
param (
# TssSession object created by New-TssSession for auth
[Parameter(Mandatory,
Expand Down Expand Up @@ -58,13 +58,19 @@
Write-Verbose "$($invokeParams.Method) $uri"
if (-not $PSCmdlet.ShouldProcess($id, "$($invokeParams.Method) $uri")) { return }
try {
Invoke-TssRestApi @invokeParams
$true
$restResponse = Invoke-TssRestApi @invokeParams
} catch {
Write-Warning "Issue removing [$id]"
$err = $_.ErrorDetails.Message
Write-Error $err
}

if ($restResponse) {
[TssDelete]@{
Id = $id
ObjectType = 'ReportCategory'
}
}
}
} else {
Write-Warning "No valid session found"
Expand Down
4 changes: 2 additions & 2 deletions tests/reports/Remove-TssReportCategory.Tests.ps1
Expand Up @@ -18,8 +18,8 @@ Describe "$commandName verify parameters" {
}
}
Context "Command specific details" {
It "$commandName should set OutputType to Boolean" -TestCases $commandDetails {
$_.OutputType.Name | Should -Be 'Boolean'
It "$commandName should set OutputType to TssDelete" -TestCases $commandDetails {
$_.OutputType.Name | Should -Be 'TssDelete'
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/secrets/Remove-TssSecret.Tests.ps1
Expand Up @@ -6,6 +6,7 @@ Describe "$commandName verify parameters" {
BeforeDiscovery {
[object[]]$knownParameters = 'TssSession', 'Id'
[object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName, 'Function')).Parameters.Keys
[object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function')
$unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru
}
Context "Verify parameters" -Foreach @{currentParams = $currentParams} {
Expand All @@ -16,4 +17,9 @@ Describe "$commandName verify parameters" {
$_ | Should -BeNullOrEmpty
}
}
Context "Command specific details" {
It "$commandName should set OutputType to TssDelete" -TestCases $commandDetails {
$_.OutputType.Name | Should -Be 'TssDelete'
}
}
}

0 comments on commit c5adf0f

Please sign in to comment.