From 676ecc17e05f8a950044070796900d65e7deb99e Mon Sep 17 00:00:00 2001 From: Roy Ashbrook Date: Mon, 8 Nov 2021 15:25:26 -0500 Subject: [PATCH] update tests to match --- .../Read-OleDbDataTests/Invoke-ExcelQuery.Tests.ps1 | 11 ++++------- .../Read-OleDbDataTests/Read-OleDbData.Tests.ps1 | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/__tests__/Read-OleDbDataTests/Invoke-ExcelQuery.Tests.ps1 b/__tests__/Read-OleDbDataTests/Invoke-ExcelQuery.Tests.ps1 index 3d0842f..4f428e2 100644 --- a/__tests__/Read-OleDbDataTests/Invoke-ExcelQuery.Tests.ps1 +++ b/__tests__/Read-OleDbDataTests/Invoke-ExcelQuery.Tests.ps1 @@ -2,15 +2,12 @@ $scriptPath = $PSScriptRoot Import-Module $scriptPath\..\..\ImportExcel.psd1 -Force $tfp = "$scriptPath\Read-OleDbData.xlsx" -$ACEnotWorking = $false -try { - $Results = Invoke-ExcelQuery $tfp "select 1" -} -catch { - $ACEnotWorking = $true +$IsMissingACE = $null -eq ((New-Object system.data.oledb.oledbenumerator).GetElements().SOURCES_NAME -like "Microsoft.ACE.OLEDB*") +if($IsMissingACE){ + Write-Host "MICROSOFT.ACE.OLEDB is missing! Tests will be skipped. Please see https://www.microsoft.com/en-us/download/details.aspx?id=54920" } Describe "Invoke-ExcelQuery" -Tag "Invoke-ExcelQuery" { - $PSDefaultParameterValues = @{ 'It:Skip' = $ACEnotWorking } + $PSDefaultParameterValues = @{ 'It:Skip' = $IsMissingACE } Context "Sheet1`$A1" { It "Should return 1 result with a value of 1" { $Results = Invoke-ExcelQuery $tfp "select ROUND(F1) as [A1] from [sheet1`$A1:A1]" diff --git a/__tests__/Read-OleDbDataTests/Read-OleDbData.Tests.ps1 b/__tests__/Read-OleDbDataTests/Read-OleDbData.Tests.ps1 index 500772f..db8ff73 100644 --- a/__tests__/Read-OleDbDataTests/Read-OleDbData.Tests.ps1 +++ b/__tests__/Read-OleDbDataTests/Read-OleDbData.Tests.ps1 @@ -2,16 +2,13 @@ $scriptPath = $PSScriptRoot Import-Module $scriptPath\..\..\ImportExcel.psd1 -Force $tfp = "$scriptPath\Read-OleDbData.xlsx" -$ACEnotWorking = $false $cs = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$tfp;Extended Properties='Excel 12.0 Xml;HDR=NO;IMEX=1;'" -try { - $Results = Read-OleDbData -ConnectionString $cs -SqlStatement "select 1" -} -catch { - $ACEnotWorking = $true +$IsMissingACE = $null -eq ((New-Object system.data.oledb.oledbenumerator).GetElements().SOURCES_NAME -like "Microsoft.ACE.OLEDB*") +if($IsMissingACE){ + Write-Host "MICROSOFT.ACE.OLEDB is missing! Tests will be skipped. Please see https://www.microsoft.com/en-us/download/details.aspx?id=54920" } Describe "Read-OleDbData" -Tag "Read-OleDbData" { - $PSDefaultParameterValues = @{ 'It:Skip' = $ACEnotWorking } + $PSDefaultParameterValues = @{ 'It:Skip' = $IsMissingACE } Context "Basic Tests" { It "should be able to open spreadsheet" { $null = Read-OleDbData -ConnectionString $cs -SqlStatement "select 1"