Skip to content

Commit db75617

Browse files
Get-TestConfig - Added configuration for temp folder (#9728)
1 parent 7f83412 commit db75617

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

private/testing/Get-TestConfig.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,9 @@ function Get-TestConfig {
7070

7171
$config['CommonParameters'] = [System.Management.Automation.PSCmdlet]::CommonParameters
7272

73+
if (-not $config['Temp']) {
74+
$config['Temp'] = 'C:\Temp'
75+
}
76+
7377
[pscustomobject]$config
7478
}

tests/Backup-DbaComputerCertificate.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Describe "Backup-DbaComputerCertificate" -Tag "IntegrationTests" {
3535
BeforeAll {
3636
$null = Add-DbaComputerCertificate -Path "$($TestConfig.appveyorlabrepo)\certificates\localhost.crt" -Confirm:$false
3737
$certThumbprint = "29C469578D6C6211076A09CEE5C5797EEA0C2713"
38-
$backupPath = "C:\temp"
38+
$backupPath = $TestConfig.Temp
3939
}
4040

4141
It "Returns the proper results" {

tests/Backup-DbaDatabase.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
1616
Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
1717

1818
Context "Properly restores a database on the local drive using Path" {
19-
$results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory C:\temp\backups
19+
$results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory "$($TestConfig.Temp)\backups"
2020
It "Should return a database name, specifically master" {
2121
($results.DatabaseName -contains 'master') | Should -Be $true
2222
}
@@ -26,7 +26,7 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
2626
}
2727

2828
BeforeAll {
29-
$DestBackupDir = 'C:\Temp\backups'
29+
$DestBackupDir = "$($TestConfig.Temp)\backups"
3030
$random = Get-Random
3131
$DestDbRandom = "dbatools_ci_backupdbadatabase$random"
3232
if (-Not(Test-Path $DestBackupDir)) {
@@ -142,10 +142,10 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
142142

143143

144144
Context "A fully qualified path should override a backupfolder" {
145-
$results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory c:\temp -BackupFileName "$DestBackupDir\PesterTest2.bak"
145+
$results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $TestConfig.Temp -BackupFileName "$DestBackupDir\PesterTest2.bak"
146146
It "Should report backed up to $DestBackupDir" {
147147
$results.FullName | Should -BeLike "$DestBackupDir\PesterTest2.bak"
148-
$results.BackupFolder | Should Not Be 'c:\temp'
148+
$results.BackupFolder | Should Not Be $TestConfig.Temp
149149
}
150150
It "Should have backuped up to $DestBackupDir\PesterTest2.bak" {
151151
Test-Path "$DestBackupDir\PesterTest2.bak" | Should -Be $true

tests/Copy-DbaDatabase.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
1515

1616
Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
1717
BeforeAll {
18-
$NetworkPath = "C:\temp"
18+
$NetworkPath = $TestConfig.Temp
1919
$random = Get-Random
2020
$backuprestoredb = "dbatoolsci_backuprestore$random"
2121
$backuprestoredb2 = "dbatoolsci_backuprestoreother$random"

0 commit comments

Comments
 (0)