Skip to content

Commit 4e7f9e8

Browse files
committed
add windows powershell tests to unit tests pipeline
1 parent d0b134b commit 4e7f9e8

3 files changed

Lines changed: 43 additions & 7 deletions

File tree

.github/workflows/run_unit_tests.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,44 @@ jobs:
7777
shell: pwsh
7878
run: |
7979
cd ${{ github.workspace }}
80+
81+
# Set up environment
82+
$testRoot = Join-Path $PWD.Path "test/unit-tests"
83+
$env:PSModulePath = "$testRoot;" + $env:PSModulePath
84+
85+
# Import test framework
86+
$frameworkPath = Join-Path $testRoot "test_framework.ps1"
87+
. $frameworkPath
88+
89+
# Import all test functions
90+
$functionsPath = Join-Path $testRoot "test_functions"
91+
Get-ChildItem $functionsPath -Filter "*.ps1" | ForEach-Object {
92+
Write-Host "Importing function: $($_.FullName)"
93+
. $_.FullName
94+
}
95+
96+
# Get list of available test functions
97+
$availableFunctions = (Get-ChildItem $functionsPath -Filter "*.ps1").BaseName
98+
Write-Host "Available test functions: $($availableFunctions -join ', ')"
99+
100+
# Find corresponding test files that have matching functions
101+
$testCasesPath = Join-Path $testRoot "test_cases"
102+
$validTestFiles = Get-ChildItem $testCasesPath -Filter "*.ps1" | Where-Object {
103+
$testName = $_.BaseName -replace "^Test-"
104+
$testName -in $availableFunctions -or
105+
$availableFunctions -contains "Get-$testName" -or
106+
$availableFunctions -contains "Is-$testName"
107+
}
108+
Write-Host "Valid test files to run: $($validTestFiles.BaseName -join ', ')"
109+
110+
# Configure Pester
80111
$config = New-PesterConfiguration
81-
$config.Run.Path = "./test/unit-tests/test_cases"
82-
$config.Run.TestExtension = ".ps1"
112+
$config.Run.Path = $validTestFiles.FullName
83113
$config.Output.Verbosity = "Detailed"
84114
$config.Run.PassThru = $true
85115
$config.TestResult.Enabled = $true
86116
$config.TestResult.OutputFormat = "NUnitXml"
87117
$config.TestResult.OutputPath = "test-results.xml"
88-
# Import test framework and functions
89-
Import-Module "./test/unit-tests/test_framework.ps1"
90-
Get-ChildItem "./test/unit-tests/test_functions" -Filter "*.ps1" | ForEach-Object {
91-
Import-Module $_.FullName -Force
92-
}
93118
# Run all test files in test_cases directory
94119
$result = Invoke-Pester -Configuration $config
95120

kubernetes/windows/main.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ function Is-CanaryRegion {
292292
return $false
293293
}
294294

295+
295296
function Get-McsGlobalEndpoint{
296297
param (
297298
[string]$cloud_environment
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function Is-CanaryRegion {
2+
param (
3+
[string]$aksRegion
4+
)
5+
$canaryRegions = @("eastus2euap", "centraluseuap")
6+
if ($canaryRegions -contains $aksRegion.ToLower()) {
7+
return $true
8+
}
9+
return $false
10+
}

0 commit comments

Comments
 (0)