Skip to content

Commit 9de0399

Browse files
Refactor some tests (#9738)
1 parent f29c76d commit 9de0399

5 files changed

+10
-16
lines changed

tests/Find-DbaStoredProcedure.Tests.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ AS
3232
$results = Find-DbaStoredProcedure -SqlInstance $TestConfig.instance2 -Pattern dbatools* -IncludeSystemDatabases
3333
It "Should find a specific StoredProcedure named cp_dbatoolsci_sysadmin" {
3434
$results.Name | Should Contain "cp_dbatoolsci_sysadmin"
35-
$results.DatabaseId | Should -Be (Get-DbaDatabase -SqlInstance $TestConfig.instance2 -Database master).ID
3635
}
3736
}
3837
Context "Command finds Procedures in a User Database" {
@@ -52,7 +51,6 @@ AS
5251
$results = Find-DbaStoredProcedure -SqlInstance $TestConfig.instance2 -Pattern dbatools* -Database 'dbatoolsci_storedproceduredb'
5352
It "Should find a specific StoredProcedure named sp_dbatoolsci_custom" {
5453
$results.Name | Should Contain "sp_dbatoolsci_custom"
55-
$results.DatabaseId | Should -Be (Get-DbaDatabase -SqlInstance $TestConfig.instance2 -Database dbatoolsci_storedproceduredb).ID
5654
}
5755
It "Should find sp_dbatoolsci_custom in dbatoolsci_storedproceduredb" {
5856
$results.Database | Should Contain "dbatoolsci_storedproceduredb"

tests/Get-DbaConnection.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
1818
$results = Get-DbaConnection -SqlInstance $TestConfig.instance1
1919
foreach ($result in $results) {
2020
It "returns an scheme" {
21-
$result.AuthScheme -eq 'ntlm' -or $result.AuthScheme -eq 'Kerberos' | Should -Be $true
21+
$result.AuthScheme | Should -BeIn 'NTLM', 'Kerberos', 'SQL'
2222
}
2323
}
2424
}

tests/Invoke-DbaDbMirroring.Tests.ps1

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,17 @@ Describe "$commandname Unit Tests" -Tag "UnitTests" {
1515

1616
Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
1717
BeforeAll {
18-
$null = Get-DbaProcess -SqlInstance $TestConfig.instance2 | Where-Object Program -Match dbatools | Stop-DbaProcess -Confirm:$false -WarningAction SilentlyContinue
1918
$server = Connect-DbaInstance -SqlInstance $TestConfig.instance2
2019
$db1 = "dbatoolsci_mirroring"
2120

22-
Remove-DbaDbMirror -SqlInstance $TestConfig.instance2 -Database $db1 -Confirm:$false
23-
Remove-DbaDatabase -SqlInstance $TestConfig.instance2 -Database $db1 -Confirm:$false
24-
$null = Get-DbaDatabase -SqlInstance $TestConfig.instance2 -Database $db1 | Remove-DbaDatabase -Confirm:$false
25-
$null = $server.Query("CREATE DATABASE $db1")
26-
27-
Get-DbaEndpoint -SqlInstance $TestConfig.instance2 -Type DatabaseMirroring | Remove-DbaEndpoint -Confirm:$false
28-
New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Name dbatoolsci_MirroringEndpoint -Type DatabaseMirroring -Port 5022 -Owner sa
29-
Get-DbaEndpoint -SqlInstance $TestConfig.instance3 -Type DatabaseMirroring | Remove-DbaEndpoint -Confirm:$false
30-
New-DbaEndpoint -SqlInstance $TestConfig.instance3 -Name dbatoolsci_MirroringEndpoint -Type DatabaseMirroring -Port 5023 -Owner sa
21+
$null = New-DbaDatabase -SqlInstance $TestConfig.instance2 -Name $db1 -EnableException
22+
$null = New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Name dbatoolsci_MirroringEndpoint -Type DatabaseMirroring -Port 5022 -Owner sa -EnableException
23+
$null = New-DbaEndpoint -SqlInstance $TestConfig.instance3 -Name dbatoolsci_MirroringEndpoint -Type DatabaseMirroring -Port 5023 -Owner sa -EnableException
3124
}
3225
AfterAll {
3326
$null = Remove-DbaDbMirror -SqlInstance $TestConfig.instance2, $TestConfig.instance3 -Database $db1 -Confirm:$false
34-
$null = Remove-DbaDatabase -Confirm:$false -SqlInstance $TestConfig.instance2, $TestConfig.instance3 -Database $db1 -ErrorAction SilentlyContinue
27+
$null = Remove-DbaDatabase -SqlInstance $TestConfig.instance2, $TestConfig.instance3 -Database $db1 -Confirm:$false
28+
$null = Remove-DbaEndpoint -SqlInstance $TestConfig.instance2, $TestConfig.instance3 -EndPoint dbatoolsci_MirroringEndpoint -Confirm:$false
3529
}
3630

3731
It "returns success" {

tests/Invoke-DbaQuery.Tests.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
5656
try {
5757
$null = $db.Query("DROP PROCEDURE dbo.dbatoolsci_procedure_example")
5858
$null = $db.Query("DROP PROCEDURE dbo.my_proc")
59+
$null = $db.Query("DROP PROCEDURE dbo.usp_Insertsomething")
60+
$null = $db.Query("DROP TYPE dbo.dbatools_tabletype")
5961
} catch {
6062
$null = 1
6163
}
@@ -85,7 +87,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
8587
}
8688
}
8789
It "supports pipable databases" {
88-
$dbs = Get-DbaDatabase -SqlInstance $TestConfig.instance2, $TestConfig.instance3
90+
$dbs = Get-DbaDatabase -SqlInstance $TestConfig.instance2, $TestConfig.instance3 -Database tempdb
8991
$results = $dbs | Invoke-DbaQuery -Query "Select 'hello' as TestColumn, DB_NAME() as dbname"
9092
foreach ($result in $results) {
9193
$result.TestColumn | Should -Be 'hello'

tests/Measure-DbaBackupThroughput.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
2222
$null = New-DbaDatabase -SqlInstance $TestConfig.instance2 -Database $db | Backup-DbaDatabase
2323
}
2424
AfterAll {
25-
$null = Remove-DbaDatabase -SqlInstance $TestConfig.instance2 -Database $db
25+
$null = Remove-DbaDatabase -SqlInstance $TestConfig.instance2 -Database $db -Confirm:$false
2626
}
2727

2828
$results = Measure-DbaBackupThroughput -SqlInstance $TestConfig.instance2 -Database $db

0 commit comments

Comments
 (0)