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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09484ef2e5522d84210a1a61d4b073e69cf0c16b9c1c04675fcb9ef0d8c734e2'
4
- data.tar.gz: 4d503946de43116dd54786eba30913c6f095e1b4bbc9d5bbce72417e0a7cac2d
3
+ metadata.gz: 035e3a6cc233184cbefdf808a6712b7fc538d89cb4bc6613e66e073514e54280
4
+ data.tar.gz: 5981514b90ce8c1ecf2f81e213f22eacd5cb88acf986b66266cadcd47f40809e
5
5
  SHA512:
6
- metadata.gz: ed143b476765bb34ee3897284f377e28e9fdd6f60072035d59007db91f7a774e5c0d0c0e975aafb856d8042796abbce77cb954ca3c53a43ba25b05bb7af5cdbd
7
- data.tar.gz: 53e54218891590a598aee9718cb5d9137f569784bf3864b8d81a7a9d860a83f8dd033d542c99e51404fe4a75de66a991bce734d4628f8823f52d0b477519c5bc
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.0"
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 = $TestPath | Join-Path -ChildPath 'PesterTestResults.xml'
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 -Path $TestPath -Passthru
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
- set-executionpolicy unrestricted -force;
149
+ try {
150
+ Set-ExecutionPolicy Unrestricted -force
151
+ }
152
+ catch {
153
+ $_ | Out-String | Write-Warning
154
+ }
155
+
145
156
  $global:ProgressPreference = 'SilentlyContinue'
146
- $env:psmodulepath += ";$(join-path (resolve-path $env:temp).path 'verifier/modules')"
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
- function directory($path){
155
- if (test-path $path) {(resolve-path $path).providerpath}
156
- else {(resolve-path (mkdir $path)).providerpath}
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
- $env:psmodulepath += ";$VerifierModulePath"
162
- function test-module($module){
163
- (get-module $module -list) -ne $null
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
- Invoke-Expression -Command $wc.DownloadString('http://bit.ly/GetPsGet')
189
- }
190
- try {
191
- import-module psget -force -erroraction stop
192
- Install-Module Pester
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
- catch {
195
- Write-Output "Installing from Github"
196
- $zipfile = join-path(resolve-path "$env:temp/verifier") "pester.zip"
197
- if (-not (test-path $zipfile)){
198
- $source = 'https://github.com/pester/Pester/archive/3.3.14.zip'
199
- $wc = New-Object -TypeName Net.WebClient
200
-
201
- if($env:http_Proxy){
202
- if($env:no_proxy){
203
- Write-Output "Creating WebProxy with 'http_proxy' and 'no_proxy' environment variables."
204
- $webproxy = New-Object System.Net.WebProxy($env:http_Proxy,$true,$env:no_proxy)
205
- }else{
206
- Write-Output "Creating WebProxy with 'http_proxy' environment variable."
207
- $webproxy = New-Object -TypeName System.Net.WebProxy -ArgumentList ($env:http_Proxy)
208
- }
209
-
210
- $wc.proxy = $webproxy
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
- [byte[]]$bytes = $wc.DownloadData($source)
214
- [IO.File]::WriteAllBytes($zipfile, $bytes)
215
- $bytes = $null
216
- [gc]::collect()
217
- write-output "Downloaded Pester.zip"
218
- }
219
- write-output "Creating Shell.Application COM object"
220
- $shellcom = new-object -com shell.application
221
- Write-Output "Creating COM object for zip file."
222
- $zipcomobject = $shellcom.namespace($zipfile)
223
- Write-Output "Creating COM object for module destination."
224
- $destination = $shellcom.namespace($VerifierModulePath)
225
- Write-Output "Unpacking zip file."
226
- $destination.CopyHere($zipcomobject.Items(), 0x610)
227
- rename-item (join-path $VerifierModulePath "Pester-3.3.14") -newname 'Pester' -force
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
- if (-not (test-module Pester)) {
232
- throw "Unable to install Pester. Please include Pester in your base image or install during your converge."
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 -command restart-service winrm" ' \
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)
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module Verifier
3
- PESTER_VERSION = "0.11.0".freeze
3
+ PESTER_VERSION = "0.12.0".freeze
4
4
  end
5
5
  end
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.11.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-02-25 00:00:00.000000000 Z
11
+ date: 2020-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler