forked from dfinke/ImportExcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvertFromExcelToSQLInsert.tests.ps1
More file actions
37 lines (27 loc) · 998 Bytes
/
Copy pathConvertFromExcelToSQLInsert.tests.ps1
File metadata and controls
37 lines (27 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
Import-Module $PSScriptRoot\..\ImportExcel.psd1
}
Describe "ConvertFrom-ExcelToSQLInsert" {
BeforeAll {
$script:xlFile = "TestDrive:\testSQL.xlsx"
}
BeforeEach {
$([PSCustomObject]@{
Name = "John"
Age = $null
}) | Export-Excel $xlFile
}
AfterAll {
Remove-Item $xlFile -Recurse -Force -ErrorAction Ignore
}
It "Should be empty double single quotes".PadRight(90) {
$expected = "INSERT INTO Sheet1 ('Name', 'Age') Values('John', '');"
$actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1
$actual | Should -Be $expected
}
It "Should have NULL".PadRight(90) {
$expected = "INSERT INTO Sheet1 ('Name', 'Age') Values('John', NULL);"
$actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1 -ConvertEmptyStringsToNull
$actual | Should -Be $expected
}
}