Class: Kitchen::Verifier::Pester
- Inherits:
-
Base
- Object
- Base
- Kitchen::Verifier::Pester
- Defined in:
- lib/kitchen/verifier/pester.rb
Instance Method Summary collapse
-
#create_sandbox ⇒ Object
Creates a temporary directory on the local workstation into which verifier related files and directories can be copied or created.
-
#init_command ⇒ String
Generates a command string which will perform any data initialization or configuration required after the verifier software is installed but before the sandbox has been transferred to the instance.
-
#initialize(config = {}) ⇒ Pester
constructor
Creates a new Verifier object using the provided configuration data which will be merged with any default configuration.
-
#install_command ⇒ String
Generates a command string which will install and configure the verifier software on an instance.
-
#local_suite_files ⇒ Array<String>
private
Returns an Array of test suite filenames for the related suite currently residing on the local workstation.
-
#prepare_command ⇒ String
Generates a command string which will perform any commands or configuration required just before the main verifier run command but after the sandbox has been transferred to the instance.
-
#prepare_pester_tests ⇒ Object
private
Copies all test suite files into the suites directory in the sandbox.
-
#run_command ⇒ String
Generates a command string which will invoke the main verifier command on the prepared instance.
-
#sandbox_suites_dir ⇒ String
private
Path to suites directory under sandbox path.
Constructor Details
#initialize(config = {}) ⇒ Pester
Creates a new Verifier object using the provided configuration data which will be merged with any default configuration.
36 37 38 |
# File 'lib/kitchen/verifier/pester.rb', line 36 def initialize(config = {}) init_config(config) end |
Instance Method Details
#create_sandbox ⇒ Object
Creates a temporary directory on the local workstation into which verifier related files and directories can be copied or created. The contents of this directory will be copied over to the instance before invoking the verifier’s run command. After this method completes, it is expected that the contents of the sandbox is complete and ready for copy to the remote instance.
Note: any subclasses would be well advised to call super first when overriding this method, for example:
58 59 60 61 |
# File 'lib/kitchen/verifier/pester.rb', line 58 def create_sandbox super prepare_pester_tests end |
#init_command ⇒ String
Generates a command string which will perform any data initialization or configuration required after the verifier software is installed but before the sandbox has been transferred to the instance. If no work is required, then nil will be returned.
89 90 |
# File 'lib/kitchen/verifier/pester.rb', line 89 def init_command end |
#install_command ⇒ String
Generates a command string which will install and configure the verifier software on an instance. If no work is required, then nil will be returned.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/kitchen/verifier/pester.rb', line 68 def install_command return if local_suite_files.empty? cmd = " if (-not (get-module -list pester)) {\n if (-not (get-module PsGet)){\n iex (new-object Net.WebClient).DownloadString('http://bit.ly/GetPsGet')\n }\n Import-Module PsGet\n Install-Module Pester\n }\n CMD\n wrap_shell_code(Util.outdent!(cmd))\nend\n" |
#local_suite_files ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an Array of test suite filenames for the related suite currently residing on the local workstation. Any special provisioner-specific directories (such as a Chef roles/ directory) are excluded.
125 126 127 128 129 130 131 |
# File 'lib/kitchen/verifier/pester.rb', line 125 def local_suite_files base = File.join(config[:test_base_path], config[:suite_name]) glob = File.join(base, "*/**/*") Dir.glob(glob).reject do |f| File.directory?(f) end end |
#prepare_command ⇒ String
Generates a command string which will perform any commands or configuration required just before the main verifier run command but after the sandbox has been transferred to the instance. If no work is required, then nil will be returned.
98 99 |
# File 'lib/kitchen/verifier/pester.rb', line 98 def prepare_command end |
#prepare_pester_tests ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Copies all test suite files into the suites directory in the sandbox.
136 137 138 139 140 141 142 143 144 |
# File 'lib/kitchen/verifier/pester.rb', line 136 def prepare_pester_tests base = File.join(config[:test_base_path], config[:suite_name]) local_suite_files.each do |src| dest = File.join(sandbox_suites_dir, src.sub("#{base}/", "")) FileUtils.mkdir_p(File.dirname(dest)) FileUtils.cp(src, dest, :preserve => true) end end |
#run_command ⇒ String
Generates a command string which will invoke the main verifier command on the prepared instance. If no work is required, then nil will be returned.
106 107 108 109 110 111 112 113 114 |
# File 'lib/kitchen/verifier/pester.rb', line 106 def run_command return if local_suite_files.empty? wrap_shell_code(Util.outdent!(" cd \"\#{File.join(config[:root_path],'suites/pester/' )}\"\n $global:ProgressPreference = 'SilentlyContinue'\n invoke-pester -enableexit\n CMD\nend\n")) |
#sandbox_suites_dir ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns path to suites directory under sandbox path.
148 149 150 |
# File 'lib/kitchen/verifier/pester.rb', line 148 def sandbox_suites_dir File.join(sandbox_path, "suites") end |