From 84c00ee40549966d552890a8c912d6546875108d Mon Sep 17 00:00:00 2001 From: Chrissy LeMaire Date: Fri, 1 Nov 2024 10:13:51 +0100 Subject: [PATCH] fixes --- ...ort-DbaPfDataCollectorSetTemplate.Tests.ps1 | 2 +- tests/Export-DbaServerRole.Tests.ps1 | 4 ++-- tests/Export-DbaSpConfigure.Tests.ps1 | 2 +- tests/Export-DbaXECsv.Tests.ps1 | 2 +- tests/Export-DbaXESessionTemplate.Tests.ps1 | 6 +++--- tests/Get-DbaConnectedInstance.Tests.ps1 | 18 +++++++++--------- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/Export-DbaPfDataCollectorSetTemplate.Tests.ps1 b/tests/Export-DbaPfDataCollectorSetTemplate.Tests.ps1 index f2d4069366..5a5b239060 100644 --- a/tests/Export-DbaPfDataCollectorSetTemplate.Tests.ps1 +++ b/tests/Export-DbaPfDataCollectorSetTemplate.Tests.ps1 @@ -10,7 +10,7 @@ Describe "Export-DbaPfDataCollectorSetTemplate" -Tag "UnitTests" { $expected = $TestConfig.CommonParameters $expected += @( "ComputerName", - "Credential", + "Credential", "CollectorSet", "Path", "FilePath", diff --git a/tests/Export-DbaServerRole.Tests.ps1 b/tests/Export-DbaServerRole.Tests.ps1 index 430aaa9586..61e3da1e97 100644 --- a/tests/Export-DbaServerRole.Tests.ps1 +++ b/tests/Export-DbaServerRole.Tests.ps1 @@ -10,7 +10,7 @@ Describe "Export-DbaServerRole" -Tag "UnitTests" { $expected = $TestConfig.CommonParameters $expected += @( 'SqlInstance', - 'SqlCredential', + 'SqlCredential', 'InputObject', 'ScriptingOptionsObject', 'ServerRole', @@ -45,7 +45,7 @@ Describe "Export-DbaServerRole" -Tags "IntegrationTests" { BeforeAll { $AltExportPath = "$env:USERPROFILE\Documents" $outputFile = "$AltExportPath\Dbatoolsci_ServerRole.sql" - + $random = Get-Random $login1 = "dbatoolsci_exportdbaserverrole_login1$random" $svRole = "dbatoolsci_ScriptPermissions$random" diff --git a/tests/Export-DbaSpConfigure.Tests.ps1 b/tests/Export-DbaSpConfigure.Tests.ps1 index f7e2805e2d..c154ca5fce 100644 --- a/tests/Export-DbaSpConfigure.Tests.ps1 +++ b/tests/Export-DbaSpConfigure.Tests.ps1 @@ -10,7 +10,7 @@ Describe "Export-DbaSpConfigure" -Tag "UnitTests" { $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", - "SqlCredential", + "SqlCredential", "Path", "FilePath", "EnableException" diff --git a/tests/Export-DbaXECsv.Tests.ps1 b/tests/Export-DbaXECsv.Tests.ps1 index fe4e265385..4c2bab6f50 100644 --- a/tests/Export-DbaXECsv.Tests.ps1 +++ b/tests/Export-DbaXECsv.Tests.ps1 @@ -10,7 +10,7 @@ Describe "Export-DbaXECsv" -Tag "UnitTests" { $expected = $TestConfig.CommonParameters $expected += @( "InputObject", - "Path", + "Path", "FilePath", "EnableException" ) diff --git a/tests/Export-DbaXESessionTemplate.Tests.ps1 b/tests/Export-DbaXESessionTemplate.Tests.ps1 index 07a1277b74..5b6898e842 100644 --- a/tests/Export-DbaXESessionTemplate.Tests.ps1 +++ b/tests/Export-DbaXESessionTemplate.Tests.ps1 @@ -10,7 +10,7 @@ Describe "Export-DbaXESessionTemplate" -Tag "UnitTests" { $expectedParams = $TestConfig.CommonParameters $expectedParams += @( 'SqlInstance', - 'SqlCredential', + 'SqlCredential', 'Session', 'Path', 'FilePath', @@ -35,12 +35,12 @@ Describe "Export-DbaXESessionTemplate" -Tag "IntegrationTests" { BeforeAll { $null = Get-DbaXESession -SqlInstance $TestConfig.instance2 -Session 'Profiler TSQL Duration' | Remove-DbaXESession } - + AfterAll { $null = Get-DbaXESession -SqlInstance $TestConfig.instance2 -Session 'Profiler TSQL Duration' | Remove-DbaXESession Remove-Item -Path 'C:\windows\temp\Profiler TSQL Duration.xml' -ErrorAction SilentlyContinue } - + Context "When exporting session template" { BeforeAll { $session = Import-DbaXESessionTemplate -SqlInstance $TestConfig.instance2 -Template 'Profiler TSQL Duration' diff --git a/tests/Get-DbaConnectedInstance.Tests.ps1 b/tests/Get-DbaConnectedInstance.Tests.ps1 index e842324d1d..ea8d9aaaa4 100644 --- a/tests/Get-DbaConnectedInstance.Tests.ps1 +++ b/tests/Get-DbaConnectedInstance.Tests.ps1 @@ -4,20 +4,20 @@ param( $PSDefaultParameterValues = ($TestConfig = Get-TestConfig).Defaults ) -# no params to test - -Describe "Get-DbaConnectedInstance" -Tag "IntegrationTests" { +Describe "Get-DbaConnectedInstance" -Tag "UnitTests" { BeforeAll { - $null = Get-DbaDatabase -SqlInstance $TestConfig.Instance1 + $command = Get-Command Get-DbaConnectedInstance + $expected = $TestConfig.CommonParameters } - Context "When getting connected instances" { - BeforeAll { - $results = Get-DbaConnectedInstance + Context "Parameter validation" { + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem } - It "Returns results" { - $results | Should -Not -BeNullOrEmpty + It "Should have exactly the number of expected parameters ($($expected.Count))" { + $hasParams = $command.Parameters.Values.Name + Compare-Object -ReferenceObject $expected -DifferenceObject $hasParams | Should -BeNullOrEmpty } } }