kitchen-pester 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/lib/kitchen/verifier/pester.rb +121 -78
- data/lib/kitchen/verifier/pester_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035e3a6cc233184cbefdf808a6712b7fc538d89cb4bc6613e66e073514e54280
|
4
|
+
data.tar.gz: 5981514b90ce8c1ecf2f81e213f22eacd5cb88acf986b66266cadcd47f40809e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad622c48d073d4f8ea62badd283dc87bc2f9d81277089a2a5078e6c00c9b9f0f8aacebbfa1e4436e8ef0d2f3e815aac3fc6b333946e5a1f5df875a7de8d9d62
|
7
|
+
data.tar.gz: c232cfd8ba4e99c94be84b6af8e3328c15d080cb6691237ff40760c8cbc2a1703dc86ec831828340a412cef38c0ffedf366cd2f6dbee4d8c514d3e5a8f8713a8
|
data/Gemfile
CHANGED
@@ -11,12 +11,12 @@ group :integration do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
group :changelog do
|
14
|
-
gem "github_changelog_generator", "1.15.
|
14
|
+
gem "github_changelog_generator", "1.15.2"
|
15
15
|
end
|
16
16
|
|
17
17
|
group :debug do
|
18
|
-
gem "pry"
|
19
|
-
gem "pry-byebug"
|
18
|
+
gem "pry", "~>0.13.1"
|
19
|
+
gem "pry-byebug", "~>3.8.0"
|
20
20
|
gem "pry-stack_explorer"
|
21
21
|
end
|
22
22
|
|
@@ -123,14 +123,19 @@ module Kitchen
|
|
123
123
|
# private
|
124
124
|
def run_command_script
|
125
125
|
<<-CMD
|
126
|
-
Import-Module Pester -Force
|
126
|
+
Import-Module -Name Pester -Force
|
127
|
+
|
127
128
|
$TestPath = "#{config[:root_path]}"
|
128
|
-
$OutputFilePath =
|
129
|
+
$OutputFilePath = Join-Path $TestPath -ChildPath 'PesterTestResults.xml'
|
130
|
+
|
131
|
+
$options = New-PesterOption -TestSuiteName "Pester - #{instance.to_str}"
|
129
132
|
|
130
|
-
$result = Invoke-Pester -OutputFile $OutputFilePath -OutputFormat NUnitXml -
|
133
|
+
$result = Invoke-Pester -Script $TestPath -OutputFile $OutputFilePath -OutputFormat NUnitXml -PesterOption $option -PassThru
|
131
134
|
$result | Export-CliXml -Path (Join-Path -Path $TestPath -ChildPath 'result.xml')
|
135
|
+
|
132
136
|
$LASTEXITCODE = $result.FailedCount
|
133
137
|
$host.SetShouldExit($LASTEXITCODE)
|
138
|
+
|
134
139
|
exit $LASTEXITCODE
|
135
140
|
CMD
|
136
141
|
end
|
@@ -141,102 +146,140 @@ module Kitchen
|
|
141
146
|
|
142
147
|
def use_local_powershell_modules(script)
|
143
148
|
<<-EOH
|
144
|
-
|
149
|
+
try {
|
150
|
+
Set-ExecutionPolicy Unrestricted -force
|
151
|
+
}
|
152
|
+
catch {
|
153
|
+
$_ | Out-String | Write-Warning
|
154
|
+
}
|
155
|
+
|
145
156
|
$global:ProgressPreference = 'SilentlyContinue'
|
146
|
-
$env:
|
157
|
+
$env:PSModulePath = "$(Join-Path (Get-Item -Path $env:TEMP).FullName -ChildPath 'verifier/modules');$env:PSModulePath"
|
158
|
+
|
147
159
|
#{script}
|
148
160
|
EOH
|
149
161
|
end
|
150
162
|
|
151
163
|
def install_command_script
|
152
164
|
<<-EOH
|
153
|
-
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
154
|
-
|
155
|
-
|
156
|
-
|
165
|
+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
166
|
+
|
167
|
+
function Confirm-Directory {
|
168
|
+
[CmdletBinding()]
|
169
|
+
param($Path)
|
170
|
+
|
171
|
+
$Item = if (Test-Path $Path) {
|
172
|
+
Get-Item -Path $Path
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
New-Item -Path $Path -ItemType Directory
|
176
|
+
}
|
177
|
+
|
178
|
+
$Item.FullName
|
157
179
|
}
|
158
|
-
$VerifierModulePath = directory $env:temp/verifier/modules
|
159
|
-
$VerifierTestsPath = directory $env:temp/verifier/pester
|
160
180
|
|
161
|
-
|
162
|
-
|
163
|
-
|
181
|
+
function Test-Module {
|
182
|
+
[CmdletBinding()]
|
183
|
+
param($Name)
|
184
|
+
|
185
|
+
@(Get-Module -Name $Name -ListAvailable -ErrorAction SilentlyContinue).Count -gt 0
|
164
186
|
}
|
165
|
-
if (-not (test-module pester)) {
|
166
|
-
if (test-module PowerShellGet){
|
167
|
-
import-module PowerShellGet -force
|
168
|
-
import-module PackageManagement -force
|
169
|
-
get-packageprovider -name NuGet -force | out-null
|
170
|
-
install-module Pester -force
|
171
|
-
}
|
172
|
-
else {
|
173
|
-
if (-not (test-module PsGet)){
|
174
|
-
$wc = New-Object -TypeName Net.WebClient
|
175
|
-
|
176
|
-
if($env:http_Proxy){
|
177
|
-
if($env:no_proxy){
|
178
|
-
Write-Output "Creating WebProxy with 'http_proxy' and 'no_proxy' environment variables.
|
179
|
-
$webproxy = New-Object System.Net.WebProxy($env:http_Proxy,$true,$env:no_proxy)
|
180
|
-
}else{
|
181
|
-
Write-Output "Creating WebProxy with 'http_proxy' environment variable.
|
182
|
-
$webproxy = New-Object -TypeName System.Net.WebProxy -ArgumentList ($env:http_Proxy)
|
183
|
-
}
|
184
|
-
|
185
|
-
$wc.proxy = $webproxy
|
186
|
-
}
|
187
187
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
188
|
+
$VerifierModulePath = Confirm-Directory -Path $env:TEMP/verifier/modules
|
189
|
+
$VerifierTestsPath = Confirm-Directory -Path $env:TEMP/verifier/pester
|
190
|
+
|
191
|
+
$env:PSModulePath = "$VerifierModulePath;$PSModulePath"
|
192
|
+
|
193
|
+
if (-not (Test-Module -Name Pester)) {
|
194
|
+
if (Test-Module -Name PowerShellGet) {
|
195
|
+
Import-Module PowerShellGet -Force
|
196
|
+
Import-Module PackageManagement -Force
|
197
|
+
|
198
|
+
Get-PackageProvider -Name NuGet -Force > $null
|
199
|
+
|
200
|
+
Install-Module Pester -Force
|
193
201
|
}
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
202
|
+
else {
|
203
|
+
if (-not (Test-Module -Name PsGet)){
|
204
|
+
$webClient = New-Object -TypeName System.Net.WebClient
|
205
|
+
|
206
|
+
if ($env:HTTP_PROXY){
|
207
|
+
if ($env:NO_PROXY){
|
208
|
+
Write-Host "Creating WebProxy with 'HTTP_PROXY' and 'NO_PROXY' environment variables.
|
209
|
+
$webproxy = New-Object -TypeName System.Net.WebProxy -ArgumentList $env:HTTP_PROXY, $true, $env:NO_PROXY
|
210
|
+
}
|
211
|
+
else {
|
212
|
+
Write-Host "Creating WebProxy with 'HTTP_PROXY' environment variable.
|
213
|
+
$webproxy = New-Object -TypeName System.Net.WebProxy -ArgumentList $env:HTTP_PROXY
|
214
|
+
}
|
215
|
+
|
216
|
+
$webClient.Proxy = $webproxy
|
217
|
+
}
|
218
|
+
|
219
|
+
Invoke-Expression -Command $webClient.DownloadString('http://bit.ly/GetPsGet')
|
211
220
|
}
|
212
221
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
222
|
+
try {
|
223
|
+
# If the module isn't already loaded, ensure we can import it.
|
224
|
+
if (-not (Get-Module -Name PsGet -ErrorAction SilentlyContinue)) {
|
225
|
+
Import-Module -Name PsGet -Force -ErrorAction Stop
|
226
|
+
}
|
227
|
+
|
228
|
+
Install-Module -Name Pester
|
229
|
+
}
|
230
|
+
catch {
|
231
|
+
Write-Host "Installing from Github"
|
232
|
+
$zipfile = Join-Path (Get-Item -Path "$env:TEMP/module").FullName -ChildPath "pester.zip"
|
233
|
+
|
234
|
+
if (-not (Test-Path $zipfile)) {
|
235
|
+
$source = 'https://github.com/pester/Pester/archive/4.10.1.zip'
|
236
|
+
$webClient = New-Object -TypeName Net.WebClient
|
237
|
+
|
238
|
+
if ($env:HTTP_PROXY) {
|
239
|
+
if ($env:NO_PROXY) {
|
240
|
+
Write-Host "Creating WebProxy with 'HTTP_PROXY' and 'NO_PROXY' environment variables."
|
241
|
+
$webproxy = New-Object -TypeName System.Net.WebProxy -ArgumentList $env:HTTP_PROXY, $true, $env:NO_PROXY
|
242
|
+
}
|
243
|
+
else {
|
244
|
+
Write-Host "Creating WebProxy with 'HTTP_PROXY' environment variable."
|
245
|
+
$webproxy = New-Object -TypeName System.Net.WebProxy -ArgumentList $env:HTTP_PROXY
|
246
|
+
}
|
247
|
+
|
248
|
+
$webClient.Proxy = $webproxy
|
249
|
+
}
|
250
|
+
|
251
|
+
[IO.File]::WriteAllBytes($zipfile, $webClient.DownloadData($source))
|
252
|
+
|
253
|
+
[GC]::Collect()
|
254
|
+
Write-Host "Downloaded Pester.zip"
|
255
|
+
}
|
256
|
+
|
257
|
+
Write-Host "Creating Shell.Application COM object"
|
258
|
+
$shellcom = New-Object -ComObject Shell.Application
|
259
|
+
|
260
|
+
Write-Host "Creating COM object for zip file."
|
261
|
+
$zipcomobject = $shellcom.Namespace($zipfile)
|
262
|
+
|
263
|
+
Write-Host "Creating COM object for module destination."
|
264
|
+
$destination = $shellcom.Namespace($VerifierModulePath)
|
265
|
+
|
266
|
+
Write-Host "Unpacking zip file."
|
267
|
+
$destination.CopyHere($zipcomobject.Items(), 0x610)
|
268
|
+
|
269
|
+
Rename-Item -Path (Join-Path $VerifierModulePath -ChildPath "Pester-4.10.1") -NewName 'Pester' -Force
|
270
|
+
}
|
228
271
|
}
|
229
|
-
}
|
230
272
|
}
|
231
|
-
|
232
|
-
|
273
|
+
|
274
|
+
if (-not (Test-Module Pester)) {
|
275
|
+
throw "Unable to install Pester. Please include Pester in your base image or install during your converge."
|
233
276
|
}
|
234
277
|
EOH
|
235
278
|
end
|
236
279
|
|
237
280
|
def restart_winrm_service
|
238
281
|
cmd = "schtasks /Create /TN restart_winrm /TR " \
|
239
|
-
'"powershell -
|
282
|
+
'"powershell -Command Restart-Service winrm" ' \
|
240
283
|
"/SC ONCE /ST 00:00 "
|
241
284
|
wrap_shell_code(Util.outdent!(<<-CMD
|
242
285
|
#{cmd}
|
@@ -252,7 +295,7 @@ module Kitchen
|
|
252
295
|
config[:downloads].to_h.each do |remotes, local|
|
253
296
|
debug("Downloading #{Array(remotes).join(", ")} to #{local}")
|
254
297
|
|
255
|
-
remotes.each do |file|
|
298
|
+
Array(remotes).each do |file|
|
256
299
|
safe_name = instance.name.gsub(/[^0-9A-Z-]/i, "_")
|
257
300
|
local_path = File.join(local, safe_name, file)
|
258
301
|
remote_path = File.join(config[:root_path], file)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-pester
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Murawski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|