@@ -177,6 +177,35 @@ Describe "Install-DBOSqlScript PostgreSQL integration tests" -Tag $commandName,
177
177
' d' | Should BeIn $testResults.name
178
178
}
179
179
}
180
+ Context " testing relative paths" {
181
+ BeforeAll {
182
+ $null = Invoke-DBOQuery @connParams - Database postgres - Query $dropDatabaseScript
183
+ [Npgsql.NpgsqlConnection ]::ClearAllPools()
184
+ $null = Invoke-DBOQuery @connParams - Database postgres - Query $createDatabaseScript
185
+ }
186
+ It " should deploy version 1.0" {
187
+ $testResults = Install-DBOSqlScript - Relative - Type PostgreSQL - ScriptPath $v1scripts - SqlInstance $script :postgresqlInstance - Credential $script :postgresqlCredential - Database $newDbName - SchemaVersionTable $logTable - Silent
188
+ $testResults.Successful | Should Be $true
189
+ $testResults.Scripts.Name | Should Be ((Resolve-Path $v1scripts - Relative) -replace ' ^.[\\|\/]' , ' ' )
190
+ $testResults.SqlInstance | Should Be $script :postgresqlInstance
191
+ $testResults.Database | Should Be $newDbName
192
+ $testResults.SourcePath | Should Be $v1scripts
193
+ $testResults.ConnectionType | Should Be ' PostgreSQL'
194
+ $testResults.Configuration.SchemaVersionTable | Should Be $logTable
195
+ $testResults.Error | Should BeNullOrEmpty
196
+ $testResults.Duration.TotalMilliseconds | Should - BeGreaterOrEqual 0
197
+ $testResults.StartTime | Should Not BeNullOrEmpty
198
+ $testResults.EndTime | Should Not BeNullOrEmpty
199
+ $testResults.EndTime | Should - BeGreaterOrEqual $testResults.StartTime
200
+ ' Upgrade successful' | Should BeIn $testResults.DeploymentLog
201
+
202
+ # Verifying objects
203
+ $testResults = Invoke-DBOQuery - Type PostgreSQL - SqlInstance $script :postgresqlInstance - Silent - Credential $script :postgresqlCredential - Database $newDbName - InputFile $verificationScript
204
+ $logTable | Should BeIn $testResults.name
205
+ ' a' | Should BeIn $testResults.name
206
+ ' b' | Should BeIn $testResults.name
207
+ }
208
+ }
180
209
Context " testing deployment order" {
181
210
BeforeAll {
182
211
$null = Invoke-DBOQuery @connParams - Database postgres - Query $dropDatabaseScript
@@ -267,6 +296,22 @@ Describe "Install-DBOSqlScript PostgreSQL integration tests" -Tag $commandName,
267
296
$output | Should BeLike ' *Successful!*'
268
297
}
269
298
}
299
+ Context " testing var replacement" {
300
+ BeforeAll {
301
+ $file = " $workFolder \vars.sql"
302
+ ' SELECT '' $a$'' ;' | Set-Content $file
303
+ }
304
+ BeforeEach {
305
+ $null = Invoke-DBOQuery @connParams - Database postgres - Query $dropDatabaseScript
306
+ [Npgsql.NpgsqlConnection ]::ClearAllPools()
307
+ $null = Invoke-DBOQuery @connParams - Database postgres - Query $createDatabaseScript
308
+ }
309
+ It " should not fail to read the script" {
310
+ $null = Install-DBOSqlScript - Absolute - Type PostgreSQL - ScriptPath " $workFolder \vars.sql" - SqlInstance $script :postgresqlInstance - Credential $script :postgresqlCredential - Database $newDbName - SchemaVersionTable $logTable - OutputFile " $workFolder \log.txt" - Silent
311
+ $output = Get-Content " $workFolder \log.txt" - Raw
312
+ $output | Should BeLike ' *$a$*'
313
+ }
314
+ }
270
315
Context " $commandName whatif tests" {
271
316
BeforeAll {
272
317
$null = Invoke-DBOQuery @connParams - Database postgres - Query $dropDatabaseScript
@@ -313,9 +358,9 @@ Describe "Install-DBOSqlScript PostgreSQL integration tests" -Tag $commandName,
313
358
It " should deploy version 1.0" {
314
359
$before = Invoke-DBOQuery - Type PostgreSQL - SqlInstance $script :postgresqlInstance - Silent - Credential $script :postgresqlCredential - Database $newDbName - InputFile $verificationScript
315
360
$rowsBefore = ($before | Measure-Object ).Count
316
- $testResults = Install-DBOSqlScript - Absolute - Type PostgreSQL - ScriptPath $v1scripts - SqlInstance $script :postgresqlInstance - Credential $script :postgresqlCredential - Database $newDbName - Silent
361
+ $testResults = Install-DBOSqlScript - Type PostgreSQL - ScriptPath $v1scripts - SqlInstance $script :postgresqlInstance - Credential $script :postgresqlCredential - Database $newDbName - Silent
317
362
$testResults.Successful | Should Be $true
318
- $testResults.Scripts.Name | Should Be (Resolve-Path $v1scripts ).Path
363
+ $testResults.Scripts.Name | Should Be (Get-Item $v1scripts ).Name
319
364
$testResults.SqlInstance | Should Be $script :postgresqlInstance
320
365
$testResults.Database | Should Be $newDbName
321
366
$testResults.SourcePath | Should Be $v1scripts
@@ -340,9 +385,9 @@ Describe "Install-DBOSqlScript PostgreSQL integration tests" -Tag $commandName,
340
385
It " should deploy version 2.0" {
341
386
$before = Invoke-DBOQuery - Type PostgreSQL - SqlInstance $script :postgresqlInstance - Silent - Credential $script :postgresqlCredential - Database $newDbName - InputFile $verificationScript
342
387
$rowsBefore = ($before | Measure-Object ).Count
343
- $testResults = Install-DBOSqlScript - Absolute - Type PostgreSQL - ScriptPath $v2scripts - SqlInstance $script :postgresqlInstance - Credential $script :postgresqlCredential - Database $newDbName - Silent
388
+ $testResults = Install-DBOSqlScript - Type PostgreSQL - ScriptPath $v2scripts - SqlInstance $script :postgresqlInstance - Credential $script :postgresqlCredential - Database $newDbName - Silent
344
389
$testResults.Successful | Should Be $true
345
- $testResults.Scripts.Name | Should Be (Resolve-Path $v2scripts ).Path
390
+ $testResults.Scripts.Name | Should Be (Get-Item $v2scripts ).Name
346
391
$testResults.SqlInstance | Should Be $script :postgresqlInstance
347
392
$testResults.Database | Should Be $newDbName
348
393
$testResults.SourcePath | Should Be $v2scripts
0 commit comments