test-kitchen 1.0.0.alpha.2 → 1.0.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +19 -1
- data/features/kitchen_init_command.feature +1 -2
- data/lib/kitchen/cli.rb +12 -0
- data/lib/kitchen/color.rb +19 -0
- data/lib/kitchen/driver.rb +5 -2
- data/lib/kitchen/driver/base.rb +3 -1
- data/lib/kitchen/driver/ssh_base.rb +1 -1
- data/lib/kitchen/generator/init.rb +17 -31
- data/lib/kitchen/generator/new_plugin.rb +3 -2
- data/lib/kitchen/util.rb +36 -14
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/driver_spec.rb +111 -0
- data/spec/kitchen/util_spec.rb +103 -0
- data/templates/plugin/kitchen.yml.erb +26 -0
- metadata +7 -2
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 1.0.0.alpha.3 / 2013-04-05
|
2
|
+
|
3
|
+
### Bug fixes
|
4
|
+
|
5
|
+
* Fix :require_chef_omnibus driver_config option to eliminate re-installation (@fnichol)
|
6
|
+
* Remove implicit Bundler dependency in `kitchen init`. (@fnichol)
|
7
|
+
|
8
|
+
### New features
|
9
|
+
|
10
|
+
* Add --auto-init flag to `kitchen test` (default: false) (@fnichol)
|
11
|
+
|
12
|
+
### Improvements
|
13
|
+
|
14
|
+
* Update base box URLs. (@fnichol)
|
15
|
+
* Extract .kitchen.yml to an ERB template & update box URLs. (@fnichol)
|
16
|
+
* Add more spec coverage. (@fnichol)
|
17
|
+
|
18
|
+
|
1
19
|
## 1.0.0.alpha.2 / 2013-03-28
|
2
20
|
|
3
21
|
### Bug fixes
|
@@ -49,4 +67,4 @@ The initial release.
|
|
49
67
|
[@ChrisLundquist]: https://github.com/ChrisLundquist
|
50
68
|
[@fnichol]: https://github.com/fnichol
|
51
69
|
[@mattray]: https://github.com/mattray
|
52
|
-
[@reset]: https://github.com/reset
|
70
|
+
[@reset]: https://github.com/reset
|
data/lib/kitchen/cli.rb
CHANGED
@@ -92,6 +92,8 @@ module Kitchen
|
|
92
92
|
:desc => "Set the log level (debug, info, warn, error, fatal)"
|
93
93
|
method_option :destroy, :aliases => "-d", :default => "passing",
|
94
94
|
:desc => "Destroy strategy to use after testing (passing, always, never)."
|
95
|
+
method_option :auto_init, :type => :boolean, :default => false,
|
96
|
+
:desc => "Invoke init command if .kitchen.yml is missing"
|
95
97
|
def test(*args)
|
96
98
|
if ! %w{passing always never}.include?(options[:destroy])
|
97
99
|
raise ArgumentError, "Destroy mode must be passing, always, or never."
|
@@ -100,6 +102,7 @@ module Kitchen
|
|
100
102
|
update_config!
|
101
103
|
banner "Starting Kitchen"
|
102
104
|
elapsed = Benchmark.measure do
|
105
|
+
ensure_initialized
|
103
106
|
destroy_mode = options[:destroy].to_sym
|
104
107
|
@task = :test
|
105
108
|
results = parse_subcommand(args.first)
|
@@ -311,6 +314,15 @@ module Kitchen
|
|
311
314
|
exit 1
|
312
315
|
end
|
313
316
|
|
317
|
+
def ensure_initialized
|
318
|
+
yaml = ENV['KITCHEN_YAML'] || '.kitchen.yml'
|
319
|
+
|
320
|
+
if options[:auto_init] && ! File.exists?(yaml)
|
321
|
+
banner "Invoking init as '#{yaml}' file is missing"
|
322
|
+
invoke "init"
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
314
326
|
def pry_prompts
|
315
327
|
[
|
316
328
|
proc { |target_self, nest_level, pry|
|
data/lib/kitchen/color.rb
CHANGED
@@ -18,7 +18,13 @@
|
|
18
18
|
|
19
19
|
module Kitchen
|
20
20
|
|
21
|
+
# Utility methods to help ouput colorized text in a terminal. The
|
22
|
+
# implementation is a compressed mashup of code from the Thor and Foreman
|
23
|
+
# projects.
|
24
|
+
#
|
25
|
+
# @author Fletcher Nichol <fnichol@nichol.ca>
|
21
26
|
module Color
|
27
|
+
|
22
28
|
ANSI = {
|
23
29
|
:reset => 0, :black => 30, :red => 31, :green => 32, :yellow => 33,
|
24
30
|
:blue => 34, :magenta => 35, :cyan => 36, :white => 37,
|
@@ -32,12 +38,25 @@ module Kitchen
|
|
32
38
|
bright_green bright_magenta bright_red bright_blue
|
33
39
|
).freeze
|
34
40
|
|
41
|
+
# Returns an ansi escaped string representing a color control sequence.
|
42
|
+
#
|
43
|
+
# @param name [Symbol] a valid color representation, taken from
|
44
|
+
# Kitchen::Color::ANSI
|
45
|
+
# @return [String] an ansi escaped string if the color is valid and an
|
46
|
+
# empty string otherwise
|
35
47
|
def self.escape(name)
|
36
48
|
return "" if name.nil?
|
37
49
|
return "" unless ansi = ANSI[name]
|
38
50
|
"\e[#{ansi}m"
|
39
51
|
end
|
40
52
|
|
53
|
+
# Returns a colorized ansi escaped string with the given color.
|
54
|
+
#
|
55
|
+
# @param str [String] a string to colorize
|
56
|
+
# @param name [Symbol] a valid color representation, taken from
|
57
|
+
# Kitchen::Color::ANSI
|
58
|
+
# @return [String] an ansi escaped string if the color is valid and an
|
59
|
+
# unescaped string otherwise
|
41
60
|
def self.colorize(str, name)
|
42
61
|
color = escape(name)
|
43
62
|
color.empty? ? str : "#{color}#{str}#{escape(:reset)}"
|
data/lib/kitchen/driver.rb
CHANGED
@@ -16,6 +16,8 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
+
require 'thor/util'
|
20
|
+
|
19
21
|
module Kitchen
|
20
22
|
|
21
23
|
module Driver
|
@@ -25,17 +27,18 @@ module Kitchen
|
|
25
27
|
# @param plugin [String] a driver plugin type, which will be constantized
|
26
28
|
# @return [Driver::Base] a driver instance
|
27
29
|
# @raise [ClientError] if a driver instance could not be created
|
30
|
+
# @raise [UserError] if the driver's dependencies could not be met
|
28
31
|
def self.for_plugin(plugin, config)
|
29
32
|
first_load = require("kitchen/driver/#{plugin}")
|
30
33
|
|
31
|
-
str_const = Util.
|
34
|
+
str_const = Thor::Util.camel_case(plugin)
|
32
35
|
klass = self.const_get(str_const)
|
33
36
|
object = klass.new(config)
|
34
37
|
object.verify_dependencies if first_load
|
35
38
|
object
|
36
39
|
rescue UserError
|
37
40
|
raise
|
38
|
-
rescue LoadError
|
41
|
+
rescue LoadError, NameError
|
39
42
|
raise ClientError, "Could not require '#{plugin}' plugin from load path"
|
40
43
|
end
|
41
44
|
end
|
data/lib/kitchen/driver/base.rb
CHANGED
@@ -16,6 +16,8 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
+
require 'thor/util'
|
20
|
+
|
19
21
|
module Kitchen
|
20
22
|
|
21
23
|
module Driver
|
@@ -139,7 +141,7 @@ module Kitchen
|
|
139
141
|
def run_command(cmd, options = {})
|
140
142
|
base_options = {
|
141
143
|
:use_sudo => config[:use_sudo],
|
142
|
-
:log_subject => Util.
|
144
|
+
:log_subject => Thor::Util.snake_case(self.class.to_s)
|
143
145
|
}.merge(options)
|
144
146
|
super(cmd, base_options)
|
145
147
|
end
|
@@ -108,7 +108,7 @@ module Kitchen
|
|
108
108
|
ssh(ssh_args, <<-INSTALL.gsub(/^ {10}/, ''))
|
109
109
|
should_update_chef() {
|
110
110
|
case "#{flag}" in
|
111
|
-
|
111
|
+
true|$(chef-solo -v | cut -d " " -f 2)) return 1 ;;
|
112
112
|
latest|*) return 0 ;;
|
113
113
|
esac
|
114
114
|
}
|
@@ -44,7 +44,9 @@ module Kitchen
|
|
44
44
|
D
|
45
45
|
|
46
46
|
def init
|
47
|
-
|
47
|
+
self.class.source_root(Kitchen.source_root.join("templates", "plugin"))
|
48
|
+
|
49
|
+
create_kitchen_yaml
|
48
50
|
|
49
51
|
rakedoc = <<-RAKE.gsub(/^ {10}/, '')
|
50
52
|
|
@@ -81,7 +83,7 @@ module Kitchen
|
|
81
83
|
|
82
84
|
private
|
83
85
|
|
84
|
-
def
|
86
|
+
def create_kitchen_yaml
|
85
87
|
cookbook_name = if File.exists?(File.expand_path('metadata.rb'))
|
86
88
|
MetadataChopper.extract('metadata.rb').first
|
87
89
|
else
|
@@ -90,34 +92,10 @@ module Kitchen
|
|
90
92
|
run_list = cookbook_name ? "recipe[#{cookbook_name}]" : nil
|
91
93
|
driver_plugin = Array(options[:driver]).first || 'dummy'
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
'run_list' => Array(run_list),
|
98
|
-
'attributes' => Hash.new
|
99
|
-
},
|
100
|
-
]
|
101
|
-
}.to_yaml
|
102
|
-
end
|
103
|
-
|
104
|
-
def platforms_hash
|
105
|
-
url_base = "https://opscode-vm.s3.amazonaws.com/vagrant/boxes"
|
106
|
-
platforms = [
|
107
|
-
{ :n => 'ubuntu', :vers => %w(12.04 10.04), :rl => "recipe[apt]" },
|
108
|
-
{ :n => 'centos', :vers => %w(6.3 5.8), :rl => "recipe[yum::epel]" },
|
109
|
-
]
|
110
|
-
platforms = platforms.map do |p|
|
111
|
-
p[:vers].map do |v|
|
112
|
-
{ 'name' => "#{p[:n]}-#{v}",
|
113
|
-
'driver_config' => {
|
114
|
-
'box' => "opscode-#{p[:n]}-#{v}",
|
115
|
-
'box_url' => "#{url_base}/opscode-#{p[:n]}-#{v}.box"
|
116
|
-
},
|
117
|
-
'run_list' => Array(p[:rl])
|
118
|
-
}
|
119
|
-
end
|
120
|
-
end.flatten
|
95
|
+
template("kitchen.yml.erb", ".kitchen.yml", {
|
96
|
+
:driver_plugin => driver_plugin.sub(/^kitchen-/, ''),
|
97
|
+
:run_list => Array(run_list)
|
98
|
+
})
|
121
99
|
end
|
122
100
|
|
123
101
|
def init_rakefile?
|
@@ -183,7 +161,7 @@ module Kitchen
|
|
183
161
|
end
|
184
162
|
|
185
163
|
def install_gem(driver_gem)
|
186
|
-
|
164
|
+
unbundlerize do
|
187
165
|
run "gem install #{driver_gem}"
|
188
166
|
end
|
189
167
|
end
|
@@ -191,6 +169,14 @@ module Kitchen
|
|
191
169
|
def not_in_file?(filename, regexp)
|
192
170
|
IO.readlines(filename).grep(regexp).empty?
|
193
171
|
end
|
172
|
+
|
173
|
+
def unbundlerize
|
174
|
+
keys = %w[BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT]
|
175
|
+
|
176
|
+
keys.each { |key| ENV["__#{key}"] = ENV[key] ; ENV.delete(key) }
|
177
|
+
yield
|
178
|
+
keys.each { |key| ENV[key] = ENV.delete("__#{key}") }
|
179
|
+
end
|
194
180
|
end
|
195
181
|
end
|
196
182
|
end
|
@@ -17,6 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
19
|
require 'thor/group'
|
20
|
+
require 'thor/util'
|
20
21
|
|
21
22
|
module Kitchen
|
22
23
|
|
@@ -42,8 +43,8 @@ module Kitchen
|
|
42
43
|
@plugin_name = plugin_name
|
43
44
|
@gem_name = "kitchen-#{plugin_name}"
|
44
45
|
@gemspec = "#{gem_name}.gemspec"
|
45
|
-
@klass_name = Util.
|
46
|
-
@constant = Util.
|
46
|
+
@klass_name = ::Thor::Util.camel_case(plugin_name)
|
47
|
+
@constant = ::Thor::Util.snake_case(plugin_name).upcase
|
47
48
|
@license = options[:license]
|
48
49
|
@author = %x{git config user.name}.chomp
|
49
50
|
@email = %x{git config user.email}.chomp
|
data/lib/kitchen/util.rb
CHANGED
@@ -20,26 +20,30 @@ module Kitchen
|
|
20
20
|
|
21
21
|
# Stateless utility methods used in different contexts. Essentially a mini
|
22
22
|
# PassiveSupport library.
|
23
|
+
#
|
24
|
+
# @author Fletcher Nichol <fnichol@nichol.ca>
|
23
25
|
module Util
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
gsub(/([A-Z+])([A-Z][a-z])/, '\1_\2').
|
33
|
-
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
34
|
-
downcase
|
35
|
-
end
|
36
|
-
|
27
|
+
# Returns the standard library Logger level constants for a given symbol
|
28
|
+
# representation.
|
29
|
+
#
|
30
|
+
# @param symbol [Symbol] symbol representation of a logger level (:debug,
|
31
|
+
# :info, :warn, :error, :fatal)
|
32
|
+
# @return [Integer] Logger::Severity constant value or nil if input is not
|
33
|
+
# valid
|
37
34
|
def self.to_logger_level(symbol)
|
38
35
|
return nil unless [:debug, :info, :warn, :error, :fatal].include?(symbol)
|
39
36
|
|
40
37
|
Logger.const_get(symbol.to_s.upcase)
|
41
38
|
end
|
42
39
|
|
40
|
+
# Returns the symbol represenation of a logging levels for a given
|
41
|
+
# standard library Logger::Severity constant.
|
42
|
+
#
|
43
|
+
# @param const [Integer] Logger::Severity constant value for a logging
|
44
|
+
# level (Logger::DEBUG, Logger::INFO, Logger::WARN, Logger::ERROR,
|
45
|
+
# Logger::FATAL)
|
46
|
+
# @return [Symbol] symbol representation of the logging level
|
43
47
|
def self.from_logger_level(const)
|
44
48
|
case const
|
45
49
|
when Logger::DEBUG then :debug
|
@@ -50,6 +54,13 @@ module Kitchen
|
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
57
|
+
# Returns a new Hash with all key values coerced to symbols. All keys
|
58
|
+
# within a Hash are coerced by calling #to_sym and hashes within arrays
|
59
|
+
# and other hashes are traversed.
|
60
|
+
#
|
61
|
+
# @param obj [Object] the hash to be processed. While intended for
|
62
|
+
# hashes, this method safely processes arbitrary objects
|
63
|
+
# @return [Object] a converted hash with all keys as symbols
|
53
64
|
def self.symbolized_hash(obj)
|
54
65
|
if obj.is_a?(Hash)
|
55
66
|
obj.inject({}) { |h, (k, v)| h[k.to_sym] = symbolized_hash(v) ; h }
|
@@ -60,16 +71,27 @@ module Kitchen
|
|
60
71
|
end
|
61
72
|
end
|
62
73
|
|
74
|
+
# Returns a new Hash with all key values coerced to strings. All keys
|
75
|
+
# within a Hash are coerced by calling #to_s and hashes with arrays
|
76
|
+
# and other hashes are traversed.
|
77
|
+
#
|
78
|
+
# @param obj [Object] the hash to be processed. While intended for
|
79
|
+
# hashes, this method safely processes arbitrary objects
|
80
|
+
# @return [Object] a converted hash with all keys as strings
|
63
81
|
def self.stringified_hash(obj)
|
64
82
|
if obj.is_a?(Hash)
|
65
|
-
obj.inject({}) { |h, (k, v)| h[k.to_s] =
|
83
|
+
obj.inject({}) { |h, (k, v)| h[k.to_s] = stringified_hash(v) ; h }
|
66
84
|
elsif obj.is_a?(Array)
|
67
|
-
obj.inject([]) { |a, v| a <<
|
85
|
+
obj.inject([]) { |a, v| a << stringified_hash(v) ; a }
|
68
86
|
else
|
69
87
|
obj
|
70
88
|
end
|
71
89
|
end
|
72
90
|
|
91
|
+
# Returns a formatted string representing a duration in seconds.
|
92
|
+
#
|
93
|
+
# @param total [Integer] the total number of seconds
|
94
|
+
# @return [String] a formatted string of the form (XmYY.00s)
|
73
95
|
def self.duration(total)
|
74
96
|
minutes = (total / 60).to_i
|
75
97
|
seconds = (total - (minutes * 60))
|
data/lib/kitchen/version.rb
CHANGED
@@ -0,0 +1,111 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2013, Fletcher Nichol
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../spec_helper'
|
20
|
+
|
21
|
+
require 'kitchen/errors'
|
22
|
+
require 'kitchen/logging'
|
23
|
+
require 'kitchen/shell_out'
|
24
|
+
require 'kitchen/driver'
|
25
|
+
require 'kitchen/driver/base'
|
26
|
+
|
27
|
+
module Kitchen
|
28
|
+
|
29
|
+
module Driver
|
30
|
+
|
31
|
+
class Coolbeans < Kitchen::Driver::Base
|
32
|
+
end
|
33
|
+
|
34
|
+
class ItDepends < Kitchen::Driver::Base
|
35
|
+
|
36
|
+
attr_reader :verify_call_count
|
37
|
+
|
38
|
+
def initialize(config = {})
|
39
|
+
@verify_call_count = 0
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def verify_dependencies
|
44
|
+
@verify_call_count += 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class UnstableDepends < Kitchen::Driver::Base
|
49
|
+
|
50
|
+
def verify_dependencies
|
51
|
+
raise UserError, "Oh noes, you don't have software!"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe Kitchen::Driver do
|
58
|
+
|
59
|
+
describe ".for_plugin" do
|
60
|
+
|
61
|
+
before do
|
62
|
+
Kitchen::Driver.stubs(:require).returns(true)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "returns a driver object of the correct class" do
|
66
|
+
driver = Kitchen::Driver.for_plugin('coolbeans', {})
|
67
|
+
|
68
|
+
driver.must_be_kind_of Kitchen::Driver::Coolbeans
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns a driver initialized with its config" do
|
72
|
+
driver = Kitchen::Driver.for_plugin('coolbeans', { :jelly => 'beans' })
|
73
|
+
|
74
|
+
driver[:jelly].must_equal 'beans'
|
75
|
+
end
|
76
|
+
|
77
|
+
it "calls #verify_dependencies on the driver object" do
|
78
|
+
driver = Kitchen::Driver.for_plugin('it_depends', {})
|
79
|
+
|
80
|
+
driver.verify_call_count.must_equal 1
|
81
|
+
end
|
82
|
+
|
83
|
+
it "calls #verify_dependencies once per driver require" do
|
84
|
+
Kitchen::Driver.stubs(:require).returns(true, false)
|
85
|
+
driver1 = Kitchen::Driver.for_plugin('it_depends', {})
|
86
|
+
driver1.verify_call_count.must_equal 1
|
87
|
+
driver2 = Kitchen::Driver.for_plugin('it_depends', {})
|
88
|
+
|
89
|
+
driver2.verify_call_count.must_equal 0
|
90
|
+
end
|
91
|
+
|
92
|
+
it "raises ClientError if the driver could not be required" do
|
93
|
+
Kitchen::Driver.stubs(:require).raises(LoadError)
|
94
|
+
|
95
|
+
proc { Kitchen::Driver.for_plugin('coolbeans', {}) }.
|
96
|
+
must_raise Kitchen::ClientError
|
97
|
+
end
|
98
|
+
|
99
|
+
it "raises ClientError if the driver's class constant could not be found" do
|
100
|
+
Kitchen::Driver.stubs(:require).returns(true) # pretend require worked
|
101
|
+
|
102
|
+
proc { Kitchen::Driver.for_plugin('nope', {}) }.
|
103
|
+
must_raise Kitchen::ClientError
|
104
|
+
end
|
105
|
+
|
106
|
+
it "raises UserError if #verify_dependencies fails" do
|
107
|
+
proc { Kitchen::Driver.for_plugin('unstable_depends', {}) }.
|
108
|
+
must_raise Kitchen::UserError
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2013, Fletcher Nichol
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../spec_helper'
|
20
|
+
|
21
|
+
require 'logger'
|
22
|
+
|
23
|
+
require 'kitchen/util'
|
24
|
+
|
25
|
+
describe Kitchen::Util do
|
26
|
+
|
27
|
+
describe '.to_logger_level' do
|
28
|
+
|
29
|
+
it "returns nil for invalid symbols" do
|
30
|
+
Kitchen::Util.to_logger_level(:nope).must_be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
%w{debug info warn error fatal}.each do |level|
|
34
|
+
it "returns Logger::#{level.upcase} for :#{level} input" do
|
35
|
+
Kitchen::Util.to_logger_level(level.to_sym).
|
36
|
+
must_equal Logger.const_get(level.upcase)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe ".from_logger_level" do
|
42
|
+
|
43
|
+
it "returns :fatal for invalid symbols" do
|
44
|
+
Kitchen::Util.from_logger_level("nope").must_equal :fatal
|
45
|
+
end
|
46
|
+
|
47
|
+
%w{debug info warn error fatal}.each do |level|
|
48
|
+
it "returns :#{level} for Logger::#{level.upcase} input" do
|
49
|
+
Kitchen::Util.from_logger_level(Logger.const_get(level.upcase)).
|
50
|
+
must_equal(level.to_sym)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ".symbolized_hash" do
|
56
|
+
|
57
|
+
it "returns itself if not a hash" do
|
58
|
+
obj = Object.new
|
59
|
+
Kitchen::Util.symbolized_hash(obj).must_equal obj
|
60
|
+
end
|
61
|
+
|
62
|
+
it "preserves a symbolized hash" do
|
63
|
+
hash = { :one => [{ :two => "three" }] }
|
64
|
+
Kitchen::Util.symbolized_hash(hash).must_equal hash
|
65
|
+
end
|
66
|
+
|
67
|
+
it "converts string keys into symbols" do
|
68
|
+
Kitchen::Util.
|
69
|
+
symbolized_hash({ "one" => [{ "two" => :three, :four => "five" }] }).
|
70
|
+
must_equal({ :one => [{ :two => :three, :four => "five" }] })
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe ".stringified_hash" do
|
75
|
+
|
76
|
+
it "returns itself if not a hash" do
|
77
|
+
obj = Object.new
|
78
|
+
Kitchen::Util.stringified_hash(obj).must_equal obj
|
79
|
+
end
|
80
|
+
|
81
|
+
it "preserves a stringified hash" do
|
82
|
+
hash = { "one" => [{ "two" => "three" }] }
|
83
|
+
Kitchen::Util.stringified_hash(hash).must_equal hash
|
84
|
+
end
|
85
|
+
|
86
|
+
it "converts symbol keys into strings" do
|
87
|
+
Kitchen::Util.
|
88
|
+
stringified_hash({ :one => [{ :two => :three, "four" => "five" }] }).
|
89
|
+
must_equal({ "one" => [{ "two" => :three, "four" => "five" }] })
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe ".duration" do
|
94
|
+
|
95
|
+
it "formats seconds to 2 digits" do
|
96
|
+
Kitchen::Util.duration(60).must_equal "(1m0.00s)"
|
97
|
+
end
|
98
|
+
|
99
|
+
it "formats large values into minutes and seconds" do
|
100
|
+
Kitchen::Util.duration(48033).must_equal "(800m33.00s)"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
driver_plugin: <%= config[:driver_plugin] %>
|
3
|
+
|
4
|
+
platforms:
|
5
|
+
- name: ubuntu-12.04
|
6
|
+
driver_config:
|
7
|
+
box: canonical-ubuntu-12.04
|
8
|
+
box_url: http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box
|
9
|
+
require_chef_omnibus: true
|
10
|
+
- name: ubuntu-10.04
|
11
|
+
driver_config:
|
12
|
+
box: opscode-ubuntu-10.04
|
13
|
+
box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_chef-11.2.0.box
|
14
|
+
- name: centos-6.3
|
15
|
+
driver_config:
|
16
|
+
box: opscode-centos-6.3
|
17
|
+
box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.3_chef-11.2.0.box
|
18
|
+
- name: centos-5.8
|
19
|
+
driver_config:
|
20
|
+
box: opscode-centos-5.8
|
21
|
+
box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.8_chef-11.2.0.box
|
22
|
+
|
23
|
+
suites:
|
24
|
+
- name: default
|
25
|
+
run_list: <%= config[:run_list].inspect %>
|
26
|
+
attributes: {}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-kitchen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: celluloid
|
@@ -372,13 +372,16 @@ files:
|
|
372
372
|
- spec/kitchen/color_spec.rb
|
373
373
|
- spec/kitchen/config_spec.rb
|
374
374
|
- spec/kitchen/driver/dummy_spec.rb
|
375
|
+
- spec/kitchen/driver_spec.rb
|
375
376
|
- spec/kitchen/instance_spec.rb
|
376
377
|
- spec/kitchen/loader/yaml_spec.rb
|
377
378
|
- spec/kitchen/platform_spec.rb
|
378
379
|
- spec/kitchen/state_file_spec.rb
|
379
380
|
- spec/kitchen/suite_spec.rb
|
381
|
+
- spec/kitchen/util_spec.rb
|
380
382
|
- spec/spec_helper.rb
|
381
383
|
- templates/plugin/driver.rb.erb
|
384
|
+
- templates/plugin/kitchen.yml.erb
|
382
385
|
- templates/plugin/license_apachev2.erb
|
383
386
|
- templates/plugin/license_gplv2.erb
|
384
387
|
- templates/plugin/license_gplv3.erb
|
@@ -421,10 +424,12 @@ test_files:
|
|
421
424
|
- spec/kitchen/color_spec.rb
|
422
425
|
- spec/kitchen/config_spec.rb
|
423
426
|
- spec/kitchen/driver/dummy_spec.rb
|
427
|
+
- spec/kitchen/driver_spec.rb
|
424
428
|
- spec/kitchen/instance_spec.rb
|
425
429
|
- spec/kitchen/loader/yaml_spec.rb
|
426
430
|
- spec/kitchen/platform_spec.rb
|
427
431
|
- spec/kitchen/state_file_spec.rb
|
428
432
|
- spec/kitchen/suite_spec.rb
|
433
|
+
- spec/kitchen/util_spec.rb
|
429
434
|
- spec/spec_helper.rb
|
430
435
|
has_rdoc:
|