-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updates the basic tests to be generic and discoverable for pull requests. - Tests that the module can be imported and that the manifest is well formed. - Updated to Pester 5 syntax with detailed output. Signed-off-by: Ryan Johnson <[email protected]>
- Loading branch information
Ryan Johnson
authored
Sep 23, 2023
1 parent
afbb702
commit f6c259a
Showing
3 changed files
with
45 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
BeforeAll { | ||
Import-Module -Name "$PSScriptRoot/../VMware.CloudFoundation.Reporting.psd1" -Force -ErrorAction Stop | ||
} | ||
|
||
Describe -Tag:('ModuleValidation') 'Module Baseline Validation' { | ||
Describe -Tag:('ModuleValidation') 'Module Basic Tests' { | ||
|
||
It 'is present' { | ||
$module = Get-Module VMware.CloudFoundation.Reporting | ||
$module = Get-Module -Name $moduleName | ||
$module | Should -Be $true | ||
} | ||
|
||
It ('passes Test-ModuleManifest') { | ||
Test-ModuleManifest -Path:("$PSScriptRoot/../VMware.CloudFoundation.Reporting.psd1") | Should -Not -BeNullOrEmpty | ||
Test-ModuleManifest -Path $moduleManifest | Should -Not -BeNullOrEmpty | ||
$? | Should -Be $true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
branches: [develop] | ||
paths: | ||
- "**.psm1" | ||
- "**.psd1" | ||
|
||
jobs: | ||
basic_tests: | ||
strategy: | ||
matrix: | ||
platform: [ubuntu-latest] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | ||
- name: Run Basic Tests | ||
working-directory: ${{ github.workspace }} | ||
run: | | ||
$moduleManifest = (Get-ChildItem -Path $env:GITHUB_WORKSPACE -Filter *.psd1).Name | ||
if ($moduleManifest) { | ||
Write-Output "SUCCESS: Manifest '$moduleManifest' found in '$env:GITHUB_WORKSPACE'." | ||
} else { | ||
Write-Output "FAILURE: Manifest not found in '$env:GITHUB_WORKSPACE'." | ||
} | ||
if ($moduleManifest -match '^(.*)\.psd1$') { | ||
$moduleName = $Matches[1] | ||
Write-Output "SUCCESS: Determining module name from manifest'$moduleManifest'." | ||
} else { | ||
Write-Error "FAILED: Determining module name from manifest '$moduleManifest'." | ||
} | ||
Import-Module -Name (Resolve-Path $moduleManifest).Path -Force -ErrorAction Stop | ||
if (Get-Module -Name $moduleName) { | ||
Write-Output "SUCCESS: Module '$moduleName' was imported." | ||
} else { | ||
Write-Error "FAILED: Module '$moduleName' was not imported." | ||
} | ||
Set-PSRepository psgallery -InstallationPolicy trusted | ||
Install-Module -Name Pester -confirm:$false -Force | ||
Invoke-Pester -Path "./.ci/pester.tests.ps1" -Output Detailed -PassThru | ||
shell: pwsh |