Skip to content

Commit

Permalink
Add missing unit tests (#4979)
Browse files Browse the repository at this point in the history
* add missing unit tests

* fix encoding
  • Loading branch information
jpomfret authored and potatoqualitee committed Jan 20, 2019
1 parent a974b18 commit 627d251
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Export-DbatoolsConfig.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'FullName', 'Module', 'Name', 'Config', 'ModuleName', 'ModuleVersion', 'Scope', 'OutPath', 'SkipUnchanged', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test are custom to the command you are writing for.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence
#>
19 changes: 19 additions & 0 deletions tests/Import-DbatoolsConfig.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'Path', 'ModuleName', 'ModuleVersion', 'Scope', 'IncludeFilter', 'ExcludeFilter', 'Peek', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test are custom to the command you are writing for.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence
#>
19 changes: 19 additions & 0 deletions tests/Invoke-DbaAgFailover.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'InputObject', 'Force', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test are custom to the command you are writing for.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence
#>
19 changes: 19 additions & 0 deletions tests/Join-DbaAvailabilityGroup.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'ClusterType', 'InputObject', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test are custom to the command you are writing for.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence
#>
19 changes: 19 additions & 0 deletions tests/Remove-DbaDbBackupRestoreHistory.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'KeepDays', 'Database', 'InputObject', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test are custom to the command you are writing for.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence
#>
19 changes: 19 additions & 0 deletions tests/Reset-DbatoolsConfig.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'ConfigurationItem', 'FullName', 'Module', 'Name', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test are custom to the command you are writing for.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence
#>
19 changes: 19 additions & 0 deletions tests/Set-DbaDbCompatibility.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'TargetCompatibility', 'InputObject', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test are custom to the command you are writing for.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence
#>
19 changes: 19 additions & 0 deletions tests/Sync-DbaAvailabilityGroup.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'Primary', 'PrimarySqlCredential', 'Secondary', 'SecondarySqlCredential', 'AvailabilityGroup', 'Exclude', 'Login', 'ExcludeLogin', 'Job', 'ExcludeJob', 'InputObject', 'Force', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test are custom to the command you are writing for.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence
#>
19 changes: 19 additions & 0 deletions tests/Unregister-DbatoolsConfig.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'ConfigurationItem', 'FullName', 'Module', 'Name', 'Scope'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
<#
Integration test are custom to the command you are writing for.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence
#>

0 comments on commit 627d251

Please sign in to comment.