-
-
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.
- Loading branch information
1 parent
413d0df
commit e1e2e94
Showing
69 changed files
with
3,548 additions
and
1,854 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,35 @@ | ||
$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 = 'InputObject', 'Path', 'FilePath', '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 "Export-DbaXECsv" -Tag "UnitTests" { | ||
BeforeAll { | ||
$command = Get-Command Export-DbaXECsv | ||
$expected = $TestConfig.CommonParameters | ||
$expected += @( | ||
"InputObject", | ||
"Path", | ||
"FilePath", | ||
"EnableException" | ||
) | ||
} | ||
|
||
Context "Parameter validation" { | ||
It "Has parameter: <_>" -ForEach $expected { | ||
$command | Should -HaveParameter $PSItem | ||
} | ||
|
||
It "Should have exactly the number of expected parameters ($($expected.Count))" { | ||
$hasparms = $command.Parameters.Values.Name | ||
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | 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.