Skip to content

Commit e8b6804

Browse files
committed
Add ModuleFast and Pester Test Running
1 parent 19fcf97 commit e8b6804

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request:
66
branches: [ main ]
77

8+
defaults:
9+
run:
10+
shell: pwsh
11+
812
jobs:
913
build:
1014
name: 👷 Build
@@ -19,13 +23,24 @@ jobs:
1923
with:
2024
path: |
2125
~/.nuget/packages
26+
~/.local/share/powershell/Modules
2227
Source/PowerShell/obj
2328
Source/PowerShell/bin
2429
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
2530
restore-keys: |
2631
${{ runner.os }}-nuget-
32+
- name: ⚡ Install PowerShell Modules
33+
uses: JustinGrote/ModuleFast-action
34+
with:
35+
update: true
2736
- name: 👷 Publish
2837
run: dotnet publish --configuration Debug
38+
- name: 🧪 Test
39+
run: |
40+
$config = New-PesterConfiguration
41+
$config.run.throw = $true
42+
$config.output.Verbosity = 'Detailed'
43+
Invoke-Pester -Configuration $config
2944
- name: 📤 Upload Artifacts
3045
uses: actions/upload-artifact@v4
3146
with:

ExcelFast.requires.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
"PlatyPS!>2.0.0-0",
3+
"Pester<6"
4+
]

Test/PowerShell/ImportCommand.Tests.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BeforeAll {
22
# Import the module - adjust path as needed for your module structure
3-
$ModulePath = (Resolve-Path "$PSScriptRoot\..\..\Release\PowerShell.dll").Path
3+
$ModulePath = (Resolve-Path "$PSScriptRoot\..\..\Release\ExcelFast.psd1").Path
44
Import-Module $ModulePath -Force
55

66
# Test file paths
@@ -15,7 +15,7 @@ BeforeAll {
1515
Describe 'Import-Excel Command Tests' {
1616
Context 'When importing a valid Excel file' {
1717
It 'Should successfully import data from Test10.xlsx' {
18-
$actual = Import-ExcelFast -Path $ValidExcelFile
18+
$actual = Import-Workbook -Path $ValidExcelFile
1919

2020
$actual | Should -Not -BeNullOrEmpty
2121
$actual.Count | Should -Be 10
@@ -28,35 +28,35 @@ Describe 'Import-Excel Command Tests' {
2828

2929
Context 'Path Parameter' {
3030
It 'Should Error for a non-existent file path' {
31-
{ Import-ExcelFast -Path $InvalidPath -ErrorAction Stop } |
31+
{ Import-Workbook -Path $InvalidPath -ErrorAction Stop } |
3232
Should -Throw -ExpectedMessage '*Excel file not found*'
3333
}
3434

3535
It 'Should Error for a non-Excel extension' {
36-
{ Import-ExcelFast -Path $NonExcelExtension -ErrorAction Stop } |
36+
{ Import-Workbook -Path $NonExcelExtension -ErrorAction Stop } |
3737
Should -Throw -ExpectedMessage 'Unsupported file type*'
3838
}
3939

4040
It 'Should Error for a non-Excel content' {
41-
{ Import-ExcelFast -Path $NonExcelContent -ErrorAction Stop } |
41+
{ Import-Workbook -Path $NonExcelContent -ErrorAction Stop } |
4242
Should -Throw -ExpectedMessage '* is not a valid Excel file.'
4343
}
4444

4545
It 'Should Error for a non-Excel zip file' {
46-
{ Import-ExcelFast -Path $NonExcelZip -ErrorAction Stop } |
46+
{ Import-Workbook -Path $NonExcelZip -ErrorAction Stop } |
4747
Should -Throw -ExpectedMessage 'Sequence contains no elements*'
4848
}
4949
}
5050

5151
Context 'When specifying sheet names' {
5252
It "Should throw an error when sheet doesn't exist" {
5353

54-
{ Import-ExcelFast -Path $ValidExcelFile -SheetName 'NonExistentSheet' -ErrorAction Stop } |
54+
{ Import-Workbook -Path $ValidExcelFile -SheetName 'NonExistentSheet' -ErrorAction Stop } |
5555
Should -Throw -ExpectedMessage "*Sheet 'NonExistentSheet' does not exist*"
5656
}
5757

5858
It 'Should import data when specifying Sheet1' {
59-
$actual = Import-ExcelFast -Path $ValidExcelFile -SheetName 'Sheet1'
59+
$actual = Import-Workbook -Path $ValidExcelFile -SheetName 'Sheet1'
6060

6161
$actual | Should -Not -BeNullOrEmpty
6262
$actual.Count | Should -Be 10
@@ -70,7 +70,7 @@ Describe 'Import-Excel Command Tests' {
7070
Context 'When importing multiple files' {
7171
It 'Should process an array of file paths' {
7272
# Use the same file twice for this test
73-
$actual = Import-ExcelFast -Path @($ValidExcelFile, $ValidExcelFile)
73+
$actual = Import-Workbook -Path @($ValidExcelFile, $ValidExcelFile)
7474

7575
# Should have twice as many results as we're reading the same file twice
7676
$actual | Should -Not -BeNullOrEmpty

0 commit comments

Comments
 (0)