Skip to content

Commit

Permalink
shorten var, fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Oct 25, 2024
1 parent fca2562 commit b5be793
Show file tree
Hide file tree
Showing 30 changed files with 151 additions and 122 deletions.
11 changes: 6 additions & 5 deletions .aider/prompts/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $master = $databases | Where-Object Name -eq "master"
$systemDbs = $databases | Where-Object Name -in "master", "model", "msdb", "tempdb"
# Required - script block for Parameters.Keys
$actualParameters = $command.Parameters.Keys | Where-Object { $PSItem -notin "WhatIf", "Confirm" }
$newParameters = $command.Parameters.Values.Name | Where-Object { $PSItem -notin "WhatIf", "Confirm" }
```

### Parameter & Variable Naming Rules
Expand Down Expand Up @@ -127,21 +127,22 @@ Describe "Get-DbaDatabase" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Get-DbaDatabase
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters
$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"Database"
)
}
It "Has parameter: <_>" -ForEach $expectedParameters {
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaAgDatabase.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaAgDatabase" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaAgDatabase
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"AvailabilityGroup",
Expand All @@ -24,12 +24,13 @@ Describe "Add-DbaAgDatabase" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaAgListener.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaAgListener" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaAgListener
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"AvailabilityGroup",
Expand All @@ -24,12 +24,13 @@ Describe "Add-DbaAgListener" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaAgReplica.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaAgReplica" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaAgReplica
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"Name",
Expand All @@ -32,12 +32,13 @@ Describe "Add-DbaAgReplica" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaComputerCertificate.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaComputerCertificate" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaComputerCertificate
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"ComputerName",
"Credential",
"SecurePassword",
Expand All @@ -21,12 +21,13 @@ Describe "Add-DbaComputerCertificate" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaDbMirrorMonitor.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ Describe "Add-DbaDbMirrorMonitor" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaDbMirrorMonitor
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"EnableException"
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaDbRoleMember.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaDbRoleMember" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaDbRoleMember
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"Database",
Expand All @@ -19,12 +19,13 @@ Describe "Add-DbaDbRoleMember" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaExtendedProperty.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaExtendedProperty" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaExtendedProperty
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"Database",
Expand All @@ -19,12 +19,13 @@ Describe "Add-DbaExtendedProperty" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions tests/Add-DbaPfDataCollectorCounter.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaPfDataCollectorCounter" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaPfDataCollectorCounter
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"ComputerName",
"Credential",
"CollectorSet",
Expand All @@ -19,12 +19,13 @@ Describe "Add-DbaPfDataCollectorCounter" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand All @@ -45,8 +46,8 @@ Describe "Add-DbaPfDataCollectorCounter" -Tag "IntegrationTests" {
CollectorSet = 'Long Running Queries'
Counter = '\LogicalDisk(*)\Avg. Disk Queue Length'
}
$results = Get-DbaPfDataCollectorSet @splatAddCounter |
Get-DbaPfDataCollector |
$results = Get-DbaPfDataCollectorSet @splatAddCounter |
Get-DbaPfDataCollector |
Add-DbaPfDataCollectorCounter @splatAddCounter
}

Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaRegServer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaRegServer" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaRegServer
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"ServerName",
Expand All @@ -25,12 +25,13 @@ Describe "Add-DbaRegServer" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaRegServerGroup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaRegServerGroup" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaRegServerGroup
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"Name",
Expand All @@ -19,12 +19,13 @@ Describe "Add-DbaRegServerGroup" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaReplArticle.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaReplArticle" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaReplArticle
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"Database",
Expand All @@ -23,12 +23,13 @@ Describe "Add-DbaReplArticle" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/Add-DbaServerRoleMember.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Describe "Add-DbaServerRoleMember" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaServerRoleMember
$expectedParameters = $TestConfig.CommonParameters
$expected = $TestConfig.CommonParameters

$expectedParameters += @(
$expected += @(
"SqlInstance",
"SqlCredential",
"ServerRole",
Expand All @@ -19,12 +19,13 @@ Describe "Add-DbaServerRoleMember" -Tag "UnitTests" {
)
}

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

It "Should have exactly the number of expected parameters" {
Compare-Object -ReferenceObject $expectedParameters -DifferenceObject $command.Parameters.Keys | Should -BeNullOrEmpty
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Expand Down
Loading

0 comments on commit b5be793

Please sign in to comment.