Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tests/Connect-DbaInstance.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,17 @@ Describe $CommandName -Tag IntegrationTests {

It "clones when using Backup-DabInstace" {
$server = Connect-DbaInstance -SqlInstance $TestConfig.InstanceMulti1 -Database tempdb
$results = Backup-DbaDatabase -SqlInstance $server -Database msdb
# The backups have to go to the shared temp folder. Without a path they land in the default
# backup folder of the instance, which is a path on the SQL Server, so the Remove-Item below
# runs against a path that does not exist on the machine running the tests and silently does
# nothing. The backup was then left behind on every remote instance, and because this file
# runs early in the suite, every later test file reported it as a leftover of its own.
$results = Backup-DbaDatabase -SqlInstance $server -Database msdb -Path $TestConfig.Temp
if ($results.FullName) {
Remove-Item -Path $results.FullName -ErrorAction SilentlyContinue
}

$results = Backup-DbaDatabase -SqlInstance $server -Database msdb -WarningVariable warn
$results = Backup-DbaDatabase -SqlInstance $server -Database msdb -Path $TestConfig.Temp -WarningVariable warn
$warn | Should -BeNullOrEmpty

if ($results.FullName) {
Expand Down
7 changes: 6 additions & 1 deletion tests/Copy-DbaDatabase.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ Describe $CommandName -Tag IntegrationTests {

# For all the backups that we want to clean up after the test, we create a directory that we can delete at the end.
# Other files can be written there as well, maybe we change the name of that variable later. But for now we focus on backups.
$NetworkPath = $TestConfig.Temp
$random = Get-Random
$NetworkPath = Join-Path -Path $TestConfig.Temp -ChildPath "dbatoolsci_copydatabase$random"
$null = New-Item -Path $NetworkPath -ItemType Directory -Force
$backuprestoredb = "dbatoolsci_backuprestore$random"
$backuprestoredb2 = "dbatoolsci_backuprestoreother$random"
$detachattachdb = "dbatoolsci_detachattach$random"
Expand Down Expand Up @@ -106,6 +107,10 @@ Describe $CommandName -Tag IntegrationTests {
}
Remove-DbaDatabase @splatRemoveSupport -ErrorAction SilentlyContinue

# The backups taken during the tests stay behind otherwise, and every test file that runs
# afterwards then reports them as leftovers of its own.
Remove-Item -Path $NetworkPath -Recurse -Force -ErrorAction SilentlyContinue

$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Invoke-DbaDbMirroring.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ Describe $CommandName -Tag IntegrationTests {
$null = Remove-DbaDatabase -SqlInstance $TestConfig.InstanceCopy1, $TestConfig.InstanceCopy2 -Database $dbName
$null = Remove-DbaEndpoint -SqlInstance $TestConfig.InstanceCopy1, $TestConfig.InstanceCopy2 -EndPoint $endpointName

# Seeding the mirror leaves the full backup and the log backup in the shared folder, and every
# test file that runs afterwards then reports them as leftovers of its own.
Get-ChildItem -Path $TestConfig.Temp -Filter "$dbName*" | Remove-Item -Force -ErrorAction SilentlyContinue

$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
}

Expand Down