Skip to content

Commit

Permalink
fix failures
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Oct 25, 2024
1 parent 664904e commit a6958ca
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
4 changes: 1 addition & 3 deletions tests/ConvertTo-DbaTimeline.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ Describe "ConvertTo-DbaTimeline" -Tag "UnitTests" {
$expected += @(
"InputObject",
"ExcludeRowLabel",
"EnableException",
"Confirm",
"WhatIf"
"EnableException"
)
}

Expand Down
24 changes: 20 additions & 4 deletions tests/Copy-DbaAgentAlert.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,34 @@ Describe "Copy-DbaAgentAlert" -Tag "IntegrationTests" {

Context "When copying alerts" {
It "Copies the sample alert" {
$results = Copy-DbaAgentAlert -Source $TestConfig.instance2 -Destination $TestConfig.instance3 -Alert $alert1
$splat = @{
Source = $TestConfig.instance2
Destination = $TestConfig.instance3
Alert = $alert1
}
$results = Copy-DbaAgentAlert @splat
$results.Name | Should -Be @('dbatoolsci test alert', 'dbatoolsci test alert')
$results.Status | Should -Be @('Successful', 'Successful')
}

It "Skips alerts where destination is missing the operator" {
$results = Copy-DbaAgentAlert -Source $TestConfig.instance2 -Destination $TestConfig.instance3 -Alert $alert2 -WarningAction SilentlyContinue
$results.Status | Should -Be @('Skipped', 'Skipped')
$splat = @{
Source = $TestConfig.instance2
Destination = $TestConfig.instance3
Alert = $alert2
WarningAction = 'SilentlyContinue'
}
$results = Copy-DbaAgentAlert @splat
$results.Status | Should -BeExactly @('Skipped', 'Skipped')
}

It "Doesn't overwrite existing alerts" {
$results = Copy-DbaAgentAlert -Source $TestConfig.instance2 -Destination $TestConfig.instance3 -Alert $alert1
$splat = @{
Source = $TestConfig.instance2
Destination = $TestConfig.instance3
Alert = $alert1
}
$results = Copy-DbaAgentAlert @splat
$results.Name | Should -Be 'dbatoolsci test alert'
$results.Status | Should -Be 'Skipped'
}
Expand Down
32 changes: 19 additions & 13 deletions tests/Copy-DbaAgentOperator.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ Describe "Copy-DbaAgentOperator" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Copy-DbaAgentOperator
$expected = $TestConfig.CommonParameters
}

It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}

It "Should have exactly the number of expected parameters" {
$expected = $TestConfig.CommonParameters
$expected += @(
"Source",
"SourceSqlCredential",
Expand All @@ -20,13 +26,6 @@ Describe "Copy-DbaAgentOperator" -Tag "UnitTests" {
"Confirm",
"WhatIf"
)
}

It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}

It "Should have exactly the number of expected parameters" {
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
Expand Down Expand Up @@ -57,17 +56,24 @@ Describe "Copy-DbaAgentOperator" -Tag "IntegrationTests" {
}

Context "When copying operators" {
BeforeAll {
$results = Copy-DbaAgentOperator -Source $TestConfig.instance2 -Destination $TestConfig.instance3 -Operator dbatoolsci_operator, dbatoolsci_operator2
}

It "Returns two results" {
$splat = @{
Source = $TestConfig.instance2
Destination = $TestConfig.instance3
Operator = @("dbatoolsci_operator", "dbatoolsci_operator2")
}
$results = Copy-DbaAgentOperator @splat
$results.Count | Should -Be 2
$results.Status | Should -Be @("Successful", "Successful")
}

It "Returns one result that's skipped when copying an existing operator" {
$skippedResults = Copy-DbaAgentOperator -Source $TestConfig.instance2 -Destination $TestConfig.instance3 -Operator dbatoolsci_operator
$splat = @{
Source = $TestConfig.instance2
Destination = $TestConfig.instance3
Operator = "dbatoolsci_operator"
}
$skippedResults = Copy-DbaAgentOperator @splat
$skippedResults.Status | Should -Be "Skipped"
}
}
Expand Down

0 comments on commit a6958ca

Please sign in to comment.