-
-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pester migration - Third batch (#9531)
- Loading branch information
1 parent
f2d3146
commit 2740d7d
Showing
47 changed files
with
2,113 additions
and
1,106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") | ||
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan | ||
$global:TestConfig = Get-TestConfig | ||
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"} | ||
param( | ||
$ModuleName = "dbatools", | ||
$PSDefaultParameterValues = ($TestConfig = Get-TestConfig).Defaults | ||
) | ||
|
||
Describe "$CommandName Unit Tests" -Tag 'UnitTests' { | ||
Context "Validate parameters" { | ||
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} | ||
[object[]]$knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'DisableJobsOnDestination', 'DisableJobsOnSource', 'ExcludeServerProperties', '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 | ||
Describe "Copy-DbaAgentServer" -Tag "UnitTests" { | ||
Context "Parameter validation" { | ||
BeforeAll { | ||
$command = Get-Command Copy-DbaAgentServer | ||
$expected = $TestConfig.CommonParameters | ||
$expected += @( | ||
"Source", | ||
"SourceSqlCredential", | ||
"Destination", | ||
"DestinationSqlCredential", | ||
"DisableJobsOnDestination", | ||
"DisableJobsOnSource", | ||
"ExcludeServerProperties", | ||
"Force", | ||
"EnableException", | ||
"Confirm", | ||
"WhatIf" | ||
) | ||
} | ||
|
||
It "Has parameter: <_>" -ForEach $expected { | ||
$command | Should -HaveParameter $PSItem | ||
} | ||
|
||
It "Should have exactly the number of expected parameters ($($expected.Count))" { | ||
$hasParams = $command.Parameters.Values.Name | ||
Compare-Object -ReferenceObject $expected -DifferenceObject $hasParams | Should -BeNullOrEmpty | ||
} | ||
} | ||
} | ||
<# | ||
Integration test should appear below and are custom to the command you are writing. | ||
Read https://github.com/dataplat/dbatools/blob/development/contributing.md#tests | ||
for more guidence. | ||
#> | ||
} |
Oops, something went wrong.