Skip to content

Commit

Permalink
Add build/tests PS scripts (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
flanakin authored Oct 26, 2023
1 parent f8f2b1a commit e0a899b
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/scripts/Build-PowerShell.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

& "$PSScriptRoot/Invoke-Task" Build.PsModule
70 changes: 70 additions & 0 deletions src/scripts/Test-PowerShell.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e0a899b

Please sign in to comment.