From a6958ca5ce7a9efb753fc6eac7a56b3fa41f4937 Mon Sep 17 00:00:00 2001 From: Chrissy LeMaire Date: Fri, 25 Oct 2024 21:03:06 +0200 Subject: [PATCH] fix failures --- tests/ConvertTo-DbaTimeline.Tests.ps1 | 4 +--- tests/Copy-DbaAgentAlert.Tests.ps1 | 24 ++++++++++++++++---- tests/Copy-DbaAgentOperator.Tests.ps1 | 32 ++++++++++++++++----------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/tests/ConvertTo-DbaTimeline.Tests.ps1 b/tests/ConvertTo-DbaTimeline.Tests.ps1 index d991df2dbc..a20c74d9da 100644 --- a/tests/ConvertTo-DbaTimeline.Tests.ps1 +++ b/tests/ConvertTo-DbaTimeline.Tests.ps1 @@ -11,9 +11,7 @@ Describe "ConvertTo-DbaTimeline" -Tag "UnitTests" { $expected += @( "InputObject", "ExcludeRowLabel", - "EnableException", - "Confirm", - "WhatIf" + "EnableException" ) } diff --git a/tests/Copy-DbaAgentAlert.Tests.ps1 b/tests/Copy-DbaAgentAlert.Tests.ps1 index 9ff4652075..95d3af3df5 100644 --- a/tests/Copy-DbaAgentAlert.Tests.ps1 +++ b/tests/Copy-DbaAgentAlert.Tests.ps1 @@ -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' } diff --git a/tests/Copy-DbaAgentOperator.Tests.ps1 b/tests/Copy-DbaAgentOperator.Tests.ps1 index 2432675c3a..9bc39c9740 100644 --- a/tests/Copy-DbaAgentOperator.Tests.ps1 +++ b/tests/Copy-DbaAgentOperator.Tests.ps1 @@ -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", @@ -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 } @@ -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" } }