@@ -33,15 +33,15 @@ Describe 'Prerequisites' {
33
33
It ' Should create SqlInstall user' {
34
34
$user = New-LocalUser - Name ' SqlInstall' - Password $password - FullName ' SQL Install User' - Description ' User for SQL installation.'
35
35
36
- $user.Name | Should - Be ' SqlInstall'
37
- (Get-LocalUser - Name ' SqlInstall' ).Name | Should - Be ' SqlInstall'
36
+ $user.Name | Should- Be ' SqlInstall'
37
+ (Get-LocalUser - Name ' SqlInstall' ).Name | Should- Be ' SqlInstall'
38
38
}
39
39
40
40
It ' Should create SqlAdmin user' {
41
41
$user = New-LocalUser - Name ' SqlAdmin' - Password $password - FullName ' SQL Admin User' - Description ' User for SQL administration.'
42
42
43
- $user.Name | Should - Be ' SqlAdmin'
44
- (Get-LocalUser - Name ' SqlAdmin' ).Name | Should - Be ' SqlAdmin'
43
+ $user.Name | Should- Be ' SqlAdmin'
44
+ (Get-LocalUser - Name ' SqlAdmin' ).Name | Should- Be ' SqlAdmin'
45
45
}
46
46
}
47
47
@@ -53,29 +53,29 @@ Describe 'Prerequisites' {
53
53
It ' Should create svc-SqlPrimary user' {
54
54
$user = New-LocalUser - Name ' svc-SqlPrimary' - Password $password - FullName ' svc-SqlPrimary' - Description ' Runs the SQL Server service.'
55
55
56
- $user.Name | Should - Be ' svc-SqlPrimary'
57
- (Get-LocalUser - Name ' svc-SqlPrimary' ).Name | Should - Be ' svc-SqlPrimary'
56
+ $user.Name | Should- Be ' svc-SqlPrimary'
57
+ (Get-LocalUser - Name ' svc-SqlPrimary' ).Name | Should- Be ' svc-SqlPrimary'
58
58
}
59
59
60
60
It ' Should create svc-SqlAgentPri user' {
61
61
$user = New-LocalUser - Name ' svc-SqlAgentPri' - Password $password - FullName ' svc-SqlAgentPri' - Description ' Runs the SQL Server Agent service.'
62
62
63
- $user.Name | Should - Be ' svc-SqlAgentPri'
64
- (Get-LocalUser - Name ' svc-SqlAgentPri' ).Name | Should - Be ' svc-SqlAgentPri'
63
+ $user.Name | Should- Be ' svc-SqlAgentPri'
64
+ (Get-LocalUser - Name ' svc-SqlAgentPri' ).Name | Should- Be ' svc-SqlAgentPri'
65
65
}
66
66
67
67
It ' Should create svc-SqlSecondary user' {
68
68
$user = New-LocalUser - Name ' svc-SqlSecondary' - Password $password - FullName ' svc-SqlSecondary' - Description ' Runs the SQL Server service.'
69
69
70
- $user.Name | Should - Be ' svc-SqlSecondary'
71
- (Get-LocalUser - Name ' svc-SqlSecondary' ).Name | Should - Be ' svc-SqlSecondary'
70
+ $user.Name | Should- Be ' svc-SqlSecondary'
71
+ (Get-LocalUser - Name ' svc-SqlSecondary' ).Name | Should- Be ' svc-SqlSecondary'
72
72
}
73
73
74
74
It ' Should create svc-SqlAgentSec user' {
75
75
$user = New-LocalUser - Name ' svc-SqlAgentSec' - Password $password - FullName ' svc-SqlAgentSec' - Description ' Runs the SQL Server Agent service.'
76
76
77
- $user.Name | Should - Be ' svc-SqlAgentSec'
78
- (Get-LocalUser - Name ' svc-SqlAgentSec' ).Name | Should - Be ' svc-SqlAgentSec'
77
+ $user.Name | Should- Be ' svc-SqlAgentSec'
78
+ (Get-LocalUser - Name ' svc-SqlAgentSec' ).Name | Should- Be ' svc-SqlAgentSec'
79
79
}
80
80
}
81
81
@@ -87,7 +87,7 @@ Describe 'Prerequisites' {
87
87
# Verify if user is part of local administrator group
88
88
$adminGroup = Get-LocalGroup - Name ' Administrators'
89
89
$adminGroupMembers = Get-LocalGroupMember - Group $adminGroup
90
- $adminGroupMembers.Name | Should - Contain (' {0}\SqlInstall' -f (Get-ComputerName ))
90
+ $adminGroupMembers.Name | Should- ContainCollection (' {0}\SqlInstall' -f (Get-ComputerName ))
91
91
}
92
92
}
93
93
@@ -97,101 +97,101 @@ Describe 'Prerequisites' {
97
97
98
98
$script :mediaFile = Save-SqlDscSqlServerMediaFile - Url $url - DestinationPath $env: TEMP - Force - Quiet - ErrorAction ' Stop'
99
99
100
- $mediaFile.Name | Should - Be ' media.iso'
100
+ $mediaFile.Name | Should- Be ' media.iso'
101
101
}
102
102
103
103
It ' Should download SQL Server 2017 media' - Tag @ (' Integration_SQL2017' ) {
104
104
$url = ' https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLServer2017-x64-ENU.iso'
105
105
106
106
$script :mediaFile = Save-SqlDscSqlServerMediaFile - Url $url - DestinationPath $env: TEMP - Force - Quiet - ErrorAction ' Stop'
107
107
108
- $mediaFile.Name | Should - Be ' media.iso'
108
+ $mediaFile.Name | Should- Be ' media.iso'
109
109
}
110
110
111
111
It ' Should download SQL Server 2019 media' - Tag @ (' Integration_SQL2019' ) {
112
112
$url = ' https://download.microsoft.com/download/d/a/2/da259851-b941-459d-989c-54a18a5d44dd/SQL2019-SSEI-Dev.exe'
113
113
114
114
$script :mediaFile = Save-SqlDscSqlServerMediaFile - Url $url - DestinationPath $env: TEMP - Force - Quiet - ErrorAction ' Stop'
115
115
116
- $mediaFile.Name | Should - Be ' media.iso'
116
+ $mediaFile.Name | Should- Be ' media.iso'
117
117
}
118
118
119
119
It ' Should download SQL Server 2022 media' - Tag @ (' Integration_SQL2022' ) {
120
120
$url = ' https://download.microsoft.com/download/c/c/9/cc9c6797-383c-4b24-8920-dc057c1de9d3/SQL2022-SSEI-Dev.exe'
121
121
122
122
$script :mediaFile = Save-SqlDscSqlServerMediaFile - Url $url - DestinationPath $env: TEMP - Force - Quiet - ErrorAction ' Stop'
123
123
124
- $mediaFile.Name | Should - Be ' media.iso'
124
+ $mediaFile.Name | Should- Be ' media.iso'
125
125
}
126
126
}
127
127
128
128
Context ' Mount SQL Server media' - Tag @ (' Integration_SQL2016' , ' Integration_SQL2017' , ' Integration_SQL2019' , ' Integration_SQL2022' ) {
129
129
It ' Should mount the media to a drive letter' {
130
130
$mountedImage = Mount-DiskImage - ImagePath $script :mediaFile
131
- $mountedImage | Should - BeOfType ' Microsoft.Management.Infrastructure.CimInstance'
131
+ $mountedImage | Should- HaveType ' Microsoft.Management.Infrastructure.CimInstance'
132
132
133
133
$mountedVolume = Get-Volume - DiskImage $mountedImage
134
- $mountedVolume.DriveLetter | Should -Not - BeNullOrEmpty
134
+ $mountedVolume.DriveLetter | Should- BeTruthy
135
135
136
136
$env: IsoDriveLetter = $mountedVolume.DriveLetter
137
- $env: IsoDriveLetter | Should -Not - BeNullOrEmpty
137
+ $env: IsoDriveLetter | Should- BeTruthy
138
138
139
139
$env: IsoDrivePath = (Get-PSDrive - Name $env: IsoDriveLetter ).Root
140
- $env: IsoDrivePath | Should - Be (' {0}:\' -f $env: IsoDriveLetter )
140
+ $env: IsoDrivePath | Should- Be (' {0}:\' -f $env: IsoDriveLetter )
141
141
}
142
142
143
143
It ' Should have set environment variable for drive letter' {
144
- $env: IsoDriveLetter | Should -Not - BeNullOrEmpty
144
+ $env: IsoDriveLetter | Should- BeTruthy
145
145
}
146
146
147
147
It ' Should have set environment variable for drive path' {
148
- $env: IsoDrivePath | Should - Be (' {0}:\' -f $env: IsoDriveLetter )
148
+ $env: IsoDrivePath | Should- Be (' {0}:\' -f $env: IsoDriveLetter )
149
149
}
150
150
}
151
151
152
152
Context ' Install correct version of module SqlServer' {
153
153
It ' Should have the minimum required version of Microsoft.PowerShell.PSResourceGet' - Tag @ (' Integration_SQL2016' , ' Integration_SQL2017' , ' Integration_SQL2019' , ' Integration_SQL2022' ) {
154
154
$module = Get-Module - Name ' Microsoft.PowerShell.PSResourceGet' - ListAvailable
155
155
156
- $module | Should - HaveCount 1
157
- $module.Version -ge ' 1.0.4.1' | Should - BeTrue
156
+ $module | Should- BeCollection - Count 1
157
+ $module.Version -ge ' 1.0.4.1' | Should- BeTrue
158
158
}
159
159
160
160
It ' Should have a resource repository PSGallery with correct URI' - Tag @ (' Integration_SQL2016' , ' Integration_SQL2017' , ' Integration_SQL2019' , ' Integration_SQL2022' ) {
161
161
$resourceRepository = Get-PSResourceRepository - Name ' PSGallery'
162
162
163
- $resourceRepository | Should - HaveCount 1
164
- $resourceRepository.Uri | Should - Be ' https://www.powershellgallery.com/api/v2'
163
+ $resourceRepository | Should- BeCollection - Count 1
164
+ $resourceRepository.Uri | Should- Be ' https://www.powershellgallery.com/api/v2'
165
165
}
166
166
167
167
It ' Should install SqlServer module version 21.1.18256' - Tag @ (' Integration_SQL2016' , ' Integration_SQL2017' , ' Integration_SQL2019' ) {
168
168
# Install-Module -Name 'SqlServer' -RequiredVersion '21.1.18256' -Force -ErrorAction 'Stop'
169
169
$module = Install-PSResource - Name ' SqlServer' - Version ' 21.1.18256' - Scope ' AllUsers' - TrustRepository - ErrorAction ' Stop' - Confirm:$false - PassThru
170
170
171
- $module | Should - HaveCount 1
172
- $module.Version -eq ' 21.1.18256' | Should - BeTrue
171
+ $module | Should- BeCollection - Count 1
172
+ $module.Version -eq ' 21.1.18256' | Should- BeTrue
173
173
}
174
174
175
175
It ' Should have SqlServer module version 21.1.18256 available' - Tag @ (' Integration_SQL2016' , ' Integration_SQL2017' , ' Integration_SQL2019' ) {
176
176
$module = Get-Module - Name ' SqlServer' - ListAvailable
177
177
178
- $module | Should - HaveCount 1
179
- $module.Version -eq ' 21.1.18256' | Should - BeTrue
178
+ $module | Should- BeCollection - Count 1
179
+ $module.Version -eq ' 21.1.18256' | Should- BeTrue
180
180
}
181
181
182
182
It ' Should install SqlServer module version 22.2.0' - Tag @ (' Integration_SQL2022' ) {
183
183
# Install-Module -Name 'SqlServer' -RequiredVersion '22.2.0' -Force -ErrorAction 'Stop'
184
184
$module = Install-PSResource - Name ' SqlServer' - Version ' 22.2.0' - Scope ' AllUsers' - TrustRepository - ErrorAction ' Stop' - Confirm:$false - PassThru
185
185
186
- $module | Should - HaveCount 1
187
- $module.Version -eq ' 22.2.0' | Should - BeTrue
186
+ $module | Should- BeCollection - Count 1
187
+ $module.Version -eq ' 22.2.0' | Should- BeTrue
188
188
}
189
189
190
190
It ' Should have SqlServer module version 22.2.0 available' - Tag @ (' Integration_SQL2022' ) {
191
191
$module = Get-Module - Name ' SqlServer' - ListAvailable
192
192
193
- $module | Should - HaveCount 1
194
- $module.Version -eq ' 22.2.0' | Should - BeTrue
193
+ $module | Should- BeCollection - Count 1
194
+ $module.Version -eq ' 22.2.0' | Should- BeTrue
195
195
}
196
196
}
197
197
@@ -201,7 +201,7 @@ Describe 'Prerequisites' {
201
201
# TODO: This fails on Appveyor, but works locally when debugging on AppVeyor. Investigate why.
202
202
$result = Invoke-Command - ComputerName ' localhost' - ScriptBlock { 1 } - ErrorAction ' Stop'
203
203
204
- $result | Should - Be 1
204
+ $result | Should- Be 1
205
205
}
206
206
}
207
207
}
0 commit comments