Skip to content

Commit 97d8afe

Browse files
Refactor the Endpoint related tests (#9732)
1 parent 90689d9 commit 97d8afe

File tree

4 files changed

+14
-26
lines changed

4 files changed

+14
-26
lines changed

tests/Copy-DbaEndpoint.Tests.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,12 @@ Describe "Copy-DbaEndpoint" -Tag "UnitTests" {
3636

3737
Describe "Copy-DbaEndpoint" -Tag "IntegrationTests" {
3838
BeforeAll {
39-
Get-DbaEndpoint -SqlInstance $TestConfig.instance2 -Type DatabaseMirroring | Remove-DbaEndpoint -Confirm:$false
40-
New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Name dbatoolsci_MirroringEndpoint -Type DatabaseMirroring -Port 5022 -Owner sa
41-
Get-DbaEndpoint -SqlInstance $TestConfig.instance3 -Type DatabaseMirroring | Remove-DbaEndpoint -Confirm:$false
39+
New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Name dbatoolsci_MirroringEndpoint -Type DatabaseMirroring -Port 5022 -Owner sa -EnableException
4240
}
4341

4442
AfterAll {
4543
Get-DbaEndpoint -SqlInstance $TestConfig.instance2 -Type DatabaseMirroring | Remove-DbaEndpoint -Confirm:$false
46-
New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Name dbatoolsci_MirroringEndpoint -Type DatabaseMirroring -Port 5022 -Owner sa
4744
Get-DbaEndpoint -SqlInstance $TestConfig.instance3 -Type DatabaseMirroring | Remove-DbaEndpoint -Confirm:$false
48-
New-DbaEndpoint -SqlInstance $TestConfig.instance3 -Name dbatoolsci_MirroringEndpoint -Type DatabaseMirroring -Port 5023 -Owner sa
4945
}
5046

5147
Context "When copying endpoints between instances" {

tests/New-DbaEndpoint.Tests.ps1

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,11 @@ Describe "$CommandName Unit Tests" -Tags "UnitTests" {
1414
}
1515

1616
Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
17-
BeforeAll {
18-
$endpoint = Get-DbaEndpoint -SqlInstance $TestConfig.instance2 | Where-Object EndpointType -eq DatabaseMirroring
19-
$create = $endpoint | Export-DbaScript -Passthru
20-
Get-DbaEndpoint -SqlInstance $TestConfig.instance2 | Where-Object EndpointType -eq DatabaseMirroring | Remove-DbaEndpoint -Confirm:$false
21-
}
2217
AfterAll {
23-
Get-DbaEndpoint -SqlInstance $TestConfig.instance2 | Where-Object EndpointType -eq DatabaseMirroring | Remove-DbaEndpoint -Confirm:$false
24-
if ($create) {
25-
Invoke-DbaQuery -SqlInstance $TestConfig.instance2 -Query "$create"
26-
}
18+
$null = Remove-DbaEndpoint -SqlInstance $TestConfig.instance2, $TestConfig.instance3 -EndPoint dbatoolsci_MirroringEndpoint -Confirm:$false
2719
}
28-
$results = New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Type DatabaseMirroring -Role Partner -Name Mirroring -Confirm:$false | Start-DbaEndpoint -Confirm:$false
20+
21+
$results = New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Type DatabaseMirroring -Role Partner -Name dbatoolsci_MirroringEndpoint -Confirm:$false | Start-DbaEndpoint -Confirm:$false
2922

3023
It "creates an endpoint of the db mirroring type" {
3124
$results.EndpointType | Should -Be 'DatabaseMirroring'

tests/Remove-DbaEndpoint.Tests.ps1

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@ Describe "$CommandName Unit Tests" -Tags "UnitTests" {
1515

1616
Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
1717
BeforeAll {
18-
$endpoint = Get-DbaEndpoint -SqlInstance $TestConfig.instance2 | Where-Object EndpointType -eq DatabaseMirroring
19-
$create = $endpoint | Export-DbaScript -Passthru
20-
$null = $endpoint | Remove-DbaEndpoint -Confirm:$false
21-
$results = New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Type DatabaseMirroring -Role Partner -Name Mirroring -Confirm:$false | Start-DbaEndpoint -Confirm:$false
22-
}
23-
AfterAll {
24-
if ($create) {
25-
Invoke-DbaQuery -SqlInstance $TestConfig.instance2 -Query "$create"
26-
}
18+
$null = New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Type DatabaseMirroring -Role Partner -Name Mirroring -EnableException -Confirm:$false | Start-DbaEndpoint -EnableException -Confirm:$false
2719
}
2820

2921
It "removes an endpoint" {

tests/Test-DbaEndpoint.Tests.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ Describe "$CommandName Unit Tests" -Tags "UnitTests" {
1414
}
1515

1616
Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
17-
It -Skip "returns success" {
18-
$results = Test-DbaEndpoint -SqlInstance $TestConfig.instance3
17+
BeforeAll {
18+
$null = New-DbaEndpoint -SqlInstance $TestConfig.instance2 -Type DatabaseMirroring -Name dbatoolsci_MirroringEndpoint -EnableException -Confirm:$false | Start-DbaEndpoint -EnableException
19+
}
20+
AfterAll {
21+
$null = Remove-DbaEndpoint -SqlInstance $TestConfig.instance2 -EndPoint dbatoolsci_MirroringEndpoint -Confirm:$false
22+
}
23+
24+
It "returns success" {
25+
$results = Test-DbaEndpoint -SqlInstance $TestConfig.instance2
1926
$results | Select-Object -First 1 -ExpandProperty Connection | Should -Be 'Success'
2027
}
2128
} #$TestConfig.instance2 for appveyor

0 commit comments

Comments
 (0)