Skip to content

Commit

Permalink
Refactor tests (do AgHadr)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasjordan committed Oct 11, 2024
1 parent c215325 commit e52ef73
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 3 additions & 1 deletion tests/Disable-DbaAgHadr.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ Describe "$CommandName Unit Tests" -Tag "UnitTests" {
}
}

# $script:instance3 is used for Availability Group tests and needs Hadr service setting enabled

Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
BeforeAll {
AfterAll {
Enable-DbaAgHadr -SqlInstance $script:instance3 -Confirm:$false -Force
}

Expand Down
10 changes: 1 addition & 9 deletions tests/Enable-DbaAgHadr.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ Describe "$CommandName Unit Tests" -Tag "UnitTests" {

Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
BeforeAll {
$current = Get-DbaAgHadr -SqlInstance $script:instance3 # for appveyor $script:instance2
if ($current.IsHadrEnabled) {
Disable-DbaAgHadr -SqlInstance $script:instance3 -Confirm:$false -WarningAction SilentlyContinue -Force
}
}
AfterAll {
if (-not $current.IsHadrEnabled) {
Disable-DbaAgHadr -SqlInstance $script:instance3 -Confirm:$false -WarningAction SilentlyContinue -Force
}
Disable-DbaAgHadr -SqlInstance $script:instance3 -Confirm:$false -Force
}

$results = Enable-DbaAgHadr -SqlInstance $script:instance3 -Confirm:$false -Force
Expand Down
6 changes: 4 additions & 2 deletions tests/Get-DbaAgHadr.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ Describe "$CommandName Unit Tests" -Tag "UnitTests" {
}
}

# $script:instance3 is used for Availability Group tests and needs Hadr service setting enabled

Describe "$CommandName Integration Test" -Tag "IntegrationTests" {
$results = Get-DbaAgHadr -SqlInstance $script:instance2
$results = Get-DbaAgHadr -SqlInstance $script:instance3
Context "Validate output" {
It "returns the correct properties" {
$results.IsHadrEnabled | Should -Not -Be $null
$results.IsHadrEnabled | Should -Be $true
}
}
}

0 comments on commit e52ef73

Please sign in to comment.