Skip to content
Permalink
Browse files

Add test for Copy-DbaEndpoint (#5476)

* rdp

* try this

* add integration test

* up depth
  • Loading branch information...
potatoqualitee committed May 3, 2019
1 parent 9e66027 commit 61415e1ad6e35a5f6b68d0dcc0592ea9a2490715
Showing with 28 additions and 6 deletions.
  1. +4 −4 appveyor.yml
  2. +24 −2 tests/Copy-DbaEndpoint.Tests.ps1
@@ -18,8 +18,8 @@ cache:
- C:\Program Files\WindowsPowerShell\Modules\PSScriptAnalyzer -> appveyor.yml
- C:\Program Files\WindowsPowerShell\Modules\Pester -> appveyor.yml

shallow_clone: true
#clone_depth: 100
#shallow_clone: true
clone_depth: 100

# Set build info
environment:
@@ -86,7 +86,7 @@ before_test:

# Setting up the local SQL Server environments
- ps: .\Tests\appveyor.sqlserver.ps1
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

test_script:
# Test with native PS version
@@ -99,4 +99,4 @@ after_test:
- ps: .\Tests\appveyor.post.ps1

# on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
@@ -5,7 +5,7 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
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','Endpoint','ExcludeEndpoint','Force','EnableException'
[object[]]$knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Endpoint', 'ExcludeEndpoint', '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
@@ -16,4 +16,26 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Integration test should appear below and are custom to the command you are writing.
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests
for more guidence.
#>
#>

Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
BeforeAll {
$endpoint = Get-DbaEndpoint -SqlInstance $script:instance2 | Where-Object EndpointType -eq DatabaseMirroring
$create = $endpoint | Export-DbaScript -Passthru
$null = $endpoint | Remove-DbaEndpoint -Confirm:$false
$results = New-DbaEndpoint -SqlInstance $script:instance2 -Type DatabaseMirroring -Role Partner -Name Mirroring -EncryptionAlgorithm RC4 -Confirm:$false
}
AfterAll {
if ($create) {
$null = Get-DbaEndpoint -SqlInstance $script:instance2, $script:instance3 | Where-Object EndpointType -eq DatabaseMirroring | Remove-DbaEndpoint -Confirm:$false
Invoke-DbaQuery -SqlInstance $script:instance2 -Query "$create"
}
}

It "copies an endpoint" {
$results = Copy-DbaEndpoint -Source $script:instance2 -Destination $script:instance3 -Endpoint Mirroring
$results.DestinationServer | Should -Be $script:instance3
$results.Status | Should -Be 'Successful'
$results.Name | Should -Be 'Mirroring'
}
}

0 comments on commit 61415e1

Please sign in to comment.
You can’t perform that action at this time.