diff --git a/src/scripts/Build-PowerShell.ps1 b/src/scripts/Build-PowerShell.ps1 new file mode 100644 index 000000000..5af869299 --- /dev/null +++ b/src/scripts/Build-PowerShell.ps1 @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +& "$PSScriptRoot/Invoke-Task" Build.PsModule \ No newline at end of file diff --git a/src/scripts/Test-PowerShell.ps1 b/src/scripts/Test-PowerShell.ps1 new file mode 100644 index 000000000..47f79e9d4 --- /dev/null +++ b/src/scripts/Test-PowerShell.ps1 @@ -0,0 +1,70 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +<# + .SYNOPSIS + Runs Pester tests. + + .PARAMETER Cost + Optional. Indicates whether to run Cost Management tests. + + .PARAMETER Data + Optional. Indicates whether to run open data tests. + + .PARAMETER Exports + Optional. Indicates whether to run Cost Management export tests. + + .PARAMETER FOCUS + Optional. Indicates whether to run FOCUS tests. + + .PARAMETER Hubs + Optional. Indicates whether to run FinOps hubs tests. + + .PARAMETER Toolkit + Optional. Indicates whether to run FinOps toolkit tests. +#> +[CmdletBinding()] +param ( + [switch] + $Cost, + + [switch] + $Data, + + [switch] + $Exports, + + [switch] + $FOCUS, + + [switch] + $Hubs, + + [switch] + $Toolkit +) + +$testsToRun = @() +if ($Cost) { $testsToRun += '*-FinOpsCost*' } +if ($Data) { $testsToRun += '*-OpenData*', '*-FinOpsPricingUnit*', '*-FinOpsRegion*', '*-FinOpsService*' } +if ($Exports) { $testsToRun += '*-FinOpsCostExport*' } +if ($FOCUS) { $testsToRun += '*-FinOpsSchema*' } +if ($Hubs) { $testsToRun += '*-FinOpsHubs*' } +if ($Toolkit) { $testsToRun += '*-FinOpsToolkit*' } + +Push-Location +Set-Location "$PSScriptRoot/../powershell/Tests/Unit" + +if ($testsToRun) +{ + $testsToRun | Select-Object -Unique | ForEach-Object { + Write-Host "Running $_" + Invoke-Pester -Path $_ -Output Detailed + } +} +else +{ + Invoke-Pester -Path * -Output Detailed +} + +Pop-Location