add back invoke tests, sync skip methods

This commit is contained in:
Roy Ashbrook
2021-11-08 17:57:44 -05:00
parent 9daefc2925
commit 9ba20b8ec8
2 changed files with 44 additions and 46 deletions

View File

@@ -1,42 +1,46 @@
# #Requires -Modules Pester #Requires -Modules Pester
# $scriptPath = $PSScriptRoot if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
# Import-Module $scriptPath\..\..\ImportExcel.psd1 -Force Import-Module $PSScriptRoot\..\ImportExcel.psd1
# $tfp = "$scriptPath\Read-OleDbData.xlsx" }
# $skip = $IsLinux -or $IsMacOS #init default, not supported on mac or linux
# try { $skip = $false
# $IsMissingACE = $null -eq ((New-Object system.data.oledb.oledbenumerator).GetElements().SOURCES_NAME -like "Microsoft.ACE.OLEDB*") if ($IsLinux -or $IsMacOS) {
# if ($IsMissingACE) { $skip = $true
# Write-Warning "MICROSOFT.ACE.OLEDB is missing! Tests will be skipped." Write-Warning "Read-OleDbData: Linux and MacOs are not supported. Skipping tests."
# } }else{
# $skip = $skip -and $IsMissingACE try {
# } if ((New-Object system.data.oledb.oledbenumerator).GetElements().SOURCES_NAME -notcontains "Microsoft.ACE.OLEDB.12.0") {
# catch { $skip = $true
# Write-Warning "Unable to get sources from System.Data.OleDb. Tests will be skipped." Write-Warning "Read-OleDbData: Microsoft.ACE.OLEDB.12.0 provider not found. Skipping tests."
# $skip = $true #this will fail if the call to get the sources fails, usually means System.Data.OleDb isn't installed/supported }
# } }
catch {
$skip = $true
Write-Warning "Read-OleDbData: Calls to System.Data.OleDb failed. Skipping tests."
}
}
# Write-Warning "`$tfp = '$tfp'" Describe "Invoke-ExcelQuery" -Tag "Invoke-ExcelQuery" {
# Write-Warning "`Test-Path $tfp = '$(Test-Path $tfp)'" $PSDefaultParameterValues = @{ 'It:Skip' = $skip }
# Write-Warning "`$IsMissingACE = '$IsMissingACE'" BeforeAll {
$tfp = "$PSScriptRoot\Read-OleDbData.xlsx"
# Describe "Invoke-ExcelQuery" -Tag "Invoke-ExcelQuery" { }
# $PSDefaultParameterValues = @{ 'It:Skip' = $skip } Context "Basic Checks" {
# Context "Basic Checks" { It "Should have a valid Test file" {
# It "Should have a valid Test file" { Test-Path $tfp | Should -Be $true
# Test-Path $tfp | Should -Be $true }
# } It "Should have the Read-OleDbData command loaded" {
# It "Should have the Read-OleDbData command loaded" { (Get-Command Read-OleDbData) -ne $null | Should -Be $true
# (Get-Command Read-OleDbData) -ne $null | Should -Be $true }
# } It "Should have the Invoke-ExcelQuery command loaded" {
# It "Should have the Invoke-ExcelQuery command loaded" { (Get-Command Invoke-ExcelQuery) -ne $null | Should -Be $true
# (Get-Command Invoke-ExcelQuery) -ne $null | Should -Be $true }
# } }
# } Context "Sheet1`$A1" {
# Context "Sheet1`$A1" { It "Should return 1 result with a value of 1" {
# It "Should return 1 result with a value of 1" { $Results = Invoke-ExcelQuery $tfp "select ROUND(F1) as [A1] from [sheet1`$A1:A1]"
# $Results = Invoke-ExcelQuery $tfp "select ROUND(F1) as [A1] from [sheet1`$A1:A1]" @($Results).length + $Results.A1 | Should -Be 2
# @($Results).length + $Results.A1 | Should -Be 2 }
# } }
# } }
# }

View File

@@ -19,18 +19,12 @@ if ($IsLinux -or $IsMacOS) {
Write-Warning "Read-OleDbData: Calls to System.Data.OleDb failed. Skipping tests." Write-Warning "Read-OleDbData: Calls to System.Data.OleDb failed. Skipping tests."
} }
} }
Describe "Read-OleDbData" -Tag "Read-OleDbData" { Describe "Read-OleDbData" -Tag "Read-OleDbData" {
$PSDefaultParameterValues = @{ 'It:Skip' = $skip } $PSDefaultParameterValues = @{ 'It:Skip' = $skip }
BeforeAll { BeforeAll {
$scriptPath = $PSScriptRoot $scriptPath = $PSScriptRoot
$tfp = "$scriptPath\Read-OleDbData.xlsx" $tfp = "$scriptPath\Read-OleDbData.xlsx"
$cs = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$tfp;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'" $cs = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$tfp;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'"
if (!$skip) {
Write-Warning "`$tfp = '$tfp'"
Write-Warning "`Test-Path $tfp = '$(Test-Path $tfp)'"
Write-Warning "`$cs = '$cs'"
}
} }
Context "Basic Tests" { Context "Basic Tests" {
It "Should have a valid Test file" { It "Should have a valid Test file" {