@@ -2,74 +2,78 @@ function Get-TestConfig {
2
2
param (
3
3
[string ]$LocalConfigPath = " $script :PSModuleRoot /tests/constants.local.ps1"
4
4
)
5
- $config = [ordered ]@ {}
5
+
6
+ $config = [ordered ]@ {
7
+ CommonParameters = [System.Management.Automation.PSCmdlet ]::CommonParameters
8
+ Defaults = [System.Management.Automation.DefaultParameterDictionary ]@ {
9
+ # We want the tests as readable as possible so we want to set Confirm globally to $false.
10
+ ' *:Confirm' = $false
11
+ # We use a global warning variable so that we can always test
12
+ # that the command does not write a warning
13
+ # or that the command does write the expected warning.
14
+ ' *:WarningVariable' = ' WarnVar'
15
+ }
16
+ # We want all the tests to only write to this location.
17
+ # When testing a remote SQL Server instance this must be a network share
18
+ # where both the SQL Server instance and the test script can write to.
19
+ Temp = ' C:\Temp'
20
+ }
6
21
7
22
if (Test-Path $LocalConfigPath ) {
8
23
. $LocalConfigPath
9
24
} elseif ($env: CODESPACES -or ($env: TERM_PROGRAM -eq ' vscode' -and $env: REMOTE_CONTAINERS )) {
10
25
$null = Set-DbatoolsInsecureConnection
26
+
11
27
$config [' Instance1' ] = " dbatools1"
12
28
$config [' Instance2' ] = " dbatools2"
13
29
$config [' Instance3' ] = " dbatools3"
14
30
$config [' Instances' ] = @ ($config [' Instance1' ], $config [' Instance2' ])
15
31
16
32
$config [' SqlCred' ] = [PSCredential ]::new(' sa' , (ConvertTo-SecureString $env: SA_PASSWORD - AsPlainText - Force))
17
- $config [' Defaults' ] = [System.Management.Automation.DefaultParameterDictionary ]@ {
18
- " *:SqlCredential" = $config [' SqlCred' ]
19
- " *:SourceSqlCredential" = $config [' SqlCred' ]
20
- " *:DestinationSqlCredential" = $config [' SqlCred' ]
21
- }
33
+ $config [' Defaults' ][' *:SqlCredential' ] = $config [' SqlCred' ]
34
+ $config [' Defaults' ][' *:SourceSqlCredential' ] = $config [' SqlCred' ]
35
+ $config [' Defaults' ][' *:DestinationSqlCredential' ] = $config [' SqlCred' ]
22
36
} elseif ($env: GITHUB_WORKSPACE ) {
23
37
$config [' DbaToolsCi_Computer' ] = " localhost"
38
+
24
39
$config [' Instance1' ] = " localhost"
25
40
$config [' Instance2' ] = " localhost:14333"
41
+ $config [' Instance3' ] = " localhost"
42
+ $config [' Instances' ] = @ ($config [' Instance1' ], $config [' Instance2' ])
43
+
26
44
$config [' Instance2SQLUserName' ] = $null # placeholders for -SqlCredential testing
27
45
$config [' Instance2SQLPassword' ] = $null
28
- $config [' Instance3' ] = " localhost"
29
46
$config [' Instance2_Detailed' ] = " localhost,14333" # Just to make sure things parse a port properly
47
+
30
48
$config [' AppveyorLabRepo' ] = " /tmp/appveyor-lab"
31
- $config [' Instances' ] = @ ($config [' Instance1' ], $config [' Instance2' ])
32
49
$config [' SsisServer' ] = " localhost\sql2016"
33
50
$config [' AzureBlob' ] = " https://dbatools.blob.core.windows.net/sql"
34
51
$config [' AzureBlobAccount' ] = " dbatools"
35
52
$config [' AzureServer' ] = ' psdbatools.database.windows.net'
36
53
$config [
' AzureSqlDbLogin' ]
= " [email protected] "
37
54
} else {
55
+ # This configuration is used for the automated test on AppVeyor
38
56
$config [' DbaToolsCi_Computer' ] = " localhost"
57
+
39
58
$config [' Instance1' ] = " localhost\sql2008r2sp2"
40
59
$config [' Instance2' ] = " localhost\sql2016"
60
+ $config [' Instance3' ] = " localhost\sql2017"
61
+ $config [' Instances' ] = @ ($config [' Instance1' ], $config [' Instance2' ])
62
+
41
63
$config [' Instance2SQLUserName' ] = $null # placeholders for -SqlCredential testing
42
64
$config [' Instance2SQLPassword' ] = $null
43
- $config [' Instance3' ] = " localhost\sql2017"
44
65
$config [' Instance2_Detailed' ] = " localhost,14333\sql2016" # Just to make sure things parse a port properly
66
+
45
67
$config [' AppveyorLabRepo' ] = " C:\github\appveyor-lab"
46
- $config [' Instances' ] = @ ($config [' Instance1' ], $config [' Instance2' ])
47
68
$config [' SsisServer' ] = " localhost\sql2016"
48
69
$config [' AzureBlob' ] = " https://dbatools.blob.core.windows.net/sql"
49
70
$config [' AzureBlobAccount' ] = " dbatools"
50
71
$config [' AzureServer' ] = ' psdbatools.database.windows.net'
51
72
$config [
' AzureSqlDbLogin' ]
= " [email protected] "
73
+
52
74
$config [' BigDatabaseBackup' ] = ' C:\github\StackOverflowMini.bak'
53
75
$config [' BigDatabaseBackupSourceUrl' ] = ' https://github.com/BrentOzarULTD/Stack-Overflow-Database/releases/download/20230114/StackOverflowMini.bak'
54
76
}
55
77
56
- if ($env: appveyor ) {
57
- $config [' Defaults' ] = [System.Management.Automation.DefaultParameterDictionary ]@ {
58
- ' *:WarningAction' = ' SilentlyContinue'
59
- }
60
- }
61
-
62
- $config [' CommonParameters' ] = [System.Management.Automation.PSCmdlet ]::CommonParameters
63
-
64
- # We want the tests as readable as possible so we want to set Confirm globally to $false
65
- $config [' Defaults' ][' *:Confirm' ] = $false
66
-
67
- # We use a global warning variable so that we can always test that the command does not write a warning
68
- $config [' Defaults' ][' *:WarningVariable' ] = ' WarnVar'
69
-
70
- if (-not $config [' Temp' ]) {
71
- $config [' Temp' ] = ' C:\Temp'
72
- }
73
-
74
78
[pscustomobject ]$config
75
79
}
0 commit comments