Skip to content

Commit

Permalink
reorg beforeall
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Oct 28, 2024
1 parent 55efb3c commit 3d2376e
Show file tree
Hide file tree
Showing 35 changed files with 601 additions and 561 deletions.
48 changes: 44 additions & 4 deletions .aider/aider.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,51 @@ function Repair-SmallThing {
$allObjects = @()

$prompts = @{
ReorgParamTest = "Move the `$expected` parameter list AND the `$TestConfig.CommonParameters` part into the BeforeAll block, placing them after the `$command` assignment. Keep them within the BeforeAll block. Do not move or modify the initial `$command` assignment.
If you can't find the `$expected` parameter list, do not make any changes.
ReorgParamTest = 'Move the `$expected` parameter list AND the `$command` setting into the BeforeAll block immediately under Describe.
If you cannot find the $expected` parameter list, do not make any changes.
BAD:
Describe "Backup-DbaDbMasterKey" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Backup-DbaDbMasterKey
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"Credential",
"Database",
"ExcludeDatabase",
"SecurePassword",
"Path",
"InputObject",
"EnableException",
"WhatIf",
"Confirm"
)
}
If it's already where it should be, do not make any changes."
GOOD:
Describe "Backup-DbaDbMasterKey" -Tag "UnitTests" {
BeforeAll {
$command = Get-Command Backup-DbaDbMasterKey
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"Credential",
"Database",
"ExcludeDatabase",
"SecurePassword",
"Path",
"InputObject",
"EnableException",
"WhatIf",
"Confirm"
)
}
Context "Parameter validation" {'
}
Write-Verbose "Available prompt types: $($prompts.Keys -join ', ')"

Expand Down
42 changes: 21 additions & 21 deletions tests/Add-DbaAgDatabase.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ param(
)

Describe "Add-DbaAgDatabase" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaAgDatabase
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"AvailabilityGroup",
"Database",
"Secondary",
"SecondarySqlCredential",
"InputObject",
"SeedingMode",
"SharedPath",
"UseLastBackup",
"AdvancedBackupParams",
"EnableException",
"Confirm",
"WhatIf"
)
}
BeforeAll {
$command = Get-Command Add-DbaAgDatabase
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"AvailabilityGroup",
"Database",
"Secondary",
"SecondarySqlCredential",
"InputObject",
"SeedingMode",
"SharedPath",
"UseLastBackup",
"AdvancedBackupParams",
"EnableException",
"Confirm",
"WhatIf"
)
}

Context "Parameter validation" {
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
Expand Down
42 changes: 21 additions & 21 deletions tests/Add-DbaAgListener.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ param(
)

Describe "Add-DbaAgListener" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaAgListener
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"AvailabilityGroup",
"Name",
"IPAddress",
"SubnetIP",
"SubnetMask",
"Port",
"Dhcp",
"Passthru",
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
}
BeforeAll {
$command = Get-Command Add-DbaAgListener
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"AvailabilityGroup",
"Name",
"IPAddress",
"SubnetIP",
"SubnetMask",
"Port",
"Dhcp",
"Passthru",
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
}

Context "Parameter validation" {
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
Expand Down
58 changes: 29 additions & 29 deletions tests/Add-DbaAgReplica.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@ param(
)

Describe "Add-DbaAgReplica" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaAgReplica
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"Name",
"ClusterType",
"AvailabilityMode",
"FailoverMode",
"BackupPriority",
"ConnectionModeInPrimaryRole",
"ConnectionModeInSecondaryRole",
"SeedingMode",
"Endpoint",
"EndpointUrl",
"Passthru",
"ReadOnlyRoutingList",
"ReadonlyRoutingConnectionUrl",
"Certificate",
"ConfigureXESession",
"SessionTimeout",
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
}
BeforeAll {
$command = Get-Command Add-DbaAgReplica
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"Name",
"ClusterType",
"AvailabilityMode",
"FailoverMode",
"BackupPriority",
"ConnectionModeInPrimaryRole",
"ConnectionModeInSecondaryRole",
"SeedingMode",
"Endpoint",
"EndpointUrl",
"Passthru",
"ReadOnlyRoutingList",
"ReadonlyRoutingConnectionUrl",
"Certificate",
"ConfigureXESession",
"SessionTimeout",
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
}

Context "Parameter validation" {
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
Expand Down
36 changes: 18 additions & 18 deletions tests/Add-DbaComputerCertificate.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ param(
)

Describe "Add-DbaComputerCertificate" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaComputerCertificate
$expected = $TestConfig.CommonParameters
$expected += @(
"ComputerName",
"Credential",
"SecurePassword",
"Certificate",
"Path",
"Store",
"Folder",
"Flag",
"EnableException",
"Confirm",
"WhatIf"
)
}
BeforeAll {
$command = Get-Command Add-DbaComputerCertificate
$expected = $TestConfig.CommonParameters
$expected += @(
"ComputerName",
"Credential",
"SecurePassword",
"Certificate",
"Path",
"Store",
"Folder",
"Flag",
"EnableException",
"Confirm",
"WhatIf"
)
}

Context "Parameter validation" {
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
Expand Down
24 changes: 12 additions & 12 deletions tests/Add-DbaDbMirrorMonitor.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ param(
)

Describe "Add-DbaDbMirrorMonitor" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaDbMirrorMonitor
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"EnableException",
"Confirm",
"WhatIf"
)
}
BeforeAll {
$command = Get-Command Add-DbaDbMirrorMonitor
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"EnableException",
"Confirm",
"WhatIf"
)
}

Context "Parameter validation" {
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
Expand Down
32 changes: 16 additions & 16 deletions tests/Add-DbaDbRoleMember.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ param(
)

Describe "Add-DbaDbRoleMember" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaDbRoleMember
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"Database",
"Role",
"Member",
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
}
BeforeAll {
$command = Get-Command Add-DbaDbRoleMember
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"Database",
"Role",
"Member",
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
}

Context "Parameter validation" {
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
Expand Down
32 changes: 16 additions & 16 deletions tests/Add-DbaExtendedProperty.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ param(
)

Describe "Add-DbaExtendedProperty" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Add-DbaExtendedProperty
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"Database",
"Name",
"Value",
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
}
BeforeAll {
$command = Get-Command Add-DbaExtendedProperty
$expected = @(
"SqlInstance",
"SqlCredential",
"Database",
"Name",
"Value",
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
$expected += $TestConfig.CommonParameters
}

Context "Parameter validation" {
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
Expand Down
Loading

0 comments on commit 3d2376e

Please sign in to comment.