-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
4abfbe3
commit 3c80231
Showing
43 changed files
with
2,836 additions
and
1,533 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,69 @@ | ||
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") | ||
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan | ||
. "$PSScriptRoot\constants.ps1" | ||
param($ModuleName = 'dbatools') | ||
|
||
Describe "Add-DbaAgListener" { | ||
BeforeAll { | ||
$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', 'Name', 'IPAddress', 'SubnetIP', 'SubnetMask', 'Port', 'Dhcp', 'Passthru', '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 | ||
BeforeAll { | ||
$CommandUnderTest = Get-Command Add-DbaAgListener | ||
} | ||
It "Should have SqlInstance as a non-mandatory parameter of type DbaInstanceParameter[]" { | ||
$CommandUnderTest | Should -HaveParameter SqlInstance -Type DbaInstanceParameter[] -Not -Mandatory | ||
} | ||
It "Should have SqlCredential as a non-mandatory parameter of type PSCredential" { | ||
$CommandUnderTest | Should -HaveParameter SqlCredential -Type PSCredential -Not -Mandatory | ||
} | ||
It "Should have AvailabilityGroup as a non-mandatory parameter of type String[]" { | ||
$CommandUnderTest | Should -HaveParameter AvailabilityGroup -Type String[] -Not -Mandatory | ||
} | ||
It "Should have Name as a non-mandatory parameter of type String" { | ||
$CommandUnderTest | Should -HaveParameter Name -Type String -Not -Mandatory | ||
} | ||
It "Should have IPAddress as a non-mandatory parameter of type IPAddress[]" { | ||
$CommandUnderTest | Should -HaveParameter IPAddress -Type IPAddress[] -Not -Mandatory | ||
} | ||
It "Should have SubnetIP as a non-mandatory parameter of type IPAddress[]" { | ||
$CommandUnderTest | Should -HaveParameter SubnetIP -Type IPAddress[] -Not -Mandatory | ||
} | ||
It "Should have SubnetMask as a non-mandatory parameter of type IPAddress[]" { | ||
$CommandUnderTest | Should -HaveParameter SubnetMask -Type IPAddress[] -Not -Mandatory | ||
} | ||
It "Should have Port as a non-mandatory parameter of type Int32" { | ||
$CommandUnderTest | Should -HaveParameter Port -Type Int32 -Not -Mandatory | ||
} | ||
It "Should have Dhcp as a non-mandatory switch parameter" { | ||
$CommandUnderTest | Should -HaveParameter Dhcp -Type Switch -Not -Mandatory | ||
} | ||
It "Should have Passthru as a non-mandatory switch parameter" { | ||
$CommandUnderTest | Should -HaveParameter Passthru -Type Switch -Not -Mandatory | ||
} | ||
It "Should have InputObject as a non-mandatory parameter of type AvailabilityGroup[]" { | ||
$CommandUnderTest | Should -HaveParameter InputObject -Type AvailabilityGroup[] -Not -Mandatory | ||
} | ||
It "Should have EnableException as a non-mandatory switch parameter" { | ||
$CommandUnderTest | Should -HaveParameter EnableException -Type Switch -Not -Mandatory | ||
} | ||
} | ||
} | ||
|
||
Describe "$commandname Integration Tests" -Tag "IntegrationTests" { | ||
BeforeAll { | ||
$agname = "dbatoolsci_ag_newlistener" | ||
$listenerName = 'dbatoolsci_listener' | ||
$ag = New-DbaAvailabilityGroup -Primary $script:instance3 -Name $agname -ClusterType None -FailoverMode Manual -Confirm:$false -Certificate dbatoolsci_AGCert | ||
} | ||
AfterEach { | ||
$null = Remove-DbaAgListener -SqlInstance $script:instance3 -Listener $listenerName -AvailabilityGroup $agname -Confirm:$false | ||
} | ||
AfterAll { | ||
$null = Remove-DbaAvailabilityGroup -SqlInstance $script:instance3 -AvailabilityGroup $agname -Confirm:$false | ||
} | ||
Context "creates a listener" { | ||
It "returns results with proper data" { | ||
Context "Command usage" { | ||
BeforeAll { | ||
$agname = "dbatoolsci_ag_newlistener" | ||
$listenerName = 'dbatoolsci_listener' | ||
$ag = New-DbaAvailabilityGroup -Primary $script:instance3 -Name $agname -ClusterType None -FailoverMode Manual -Confirm:$false -Certificate dbatoolsci_AGCert | ||
} | ||
AfterEach { | ||
$null = Remove-DbaAgListener -SqlInstance $script:instance3 -Listener $listenerName -AvailabilityGroup $agname -Confirm:$false | ||
} | ||
AfterAll { | ||
$null = Remove-DbaAvailabilityGroup -SqlInstance $script:instance3 -AvailabilityGroup $agname -Confirm:$false | ||
} | ||
It "creates a listener and returns results with proper data" { | ||
$results = $ag | Add-DbaAgListener -Name $listenerName -IPAddress 127.0.20.1 -Port 14330 -Confirm:$false | ||
$results.PortNumber | Should -Be 14330 | ||
} | ||
} | ||
} #$script:instance2 for appveyor | ||
} #$script:instance2 for appveyor |
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
Oops, something went wrong.