test-kitchen 0.7.0 → 1.0.0.alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/.travis.yml +11 -0
- data/.yardopts +3 -0
- data/Gemfile +13 -0
- data/Guardfile +11 -0
- data/LICENSE +15 -0
- data/README.md +131 -0
- data/Rakefile +69 -0
- data/bin/kitchen +9 -4
- data/features/cli.feature +17 -0
- data/features/cli_init.feature +156 -0
- data/features/support/env.rb +14 -0
- data/lib/kitchen/busser.rb +166 -0
- data/lib/kitchen/chef_data_uploader.rb +156 -0
- data/lib/kitchen/cli.rb +540 -0
- data/lib/kitchen/collection.rb +55 -0
- data/lib/kitchen/color.rb +46 -0
- data/lib/kitchen/config.rb +223 -0
- data/lib/kitchen/driver/base.rb +180 -0
- data/lib/kitchen/driver/dummy.rb +81 -0
- data/lib/kitchen/driver/ssh_base.rb +192 -0
- data/lib/kitchen/driver.rb +42 -0
- data/lib/kitchen/errors.rb +52 -0
- data/lib/kitchen/instance.rb +327 -0
- data/lib/kitchen/instance_actor.rb +42 -0
- data/lib/kitchen/loader/yaml.rb +105 -0
- data/lib/kitchen/logger.rb +145 -0
- data/{cookbooks/test-kitchen/libraries/helpers.rb → lib/kitchen/logging.rb} +13 -9
- data/lib/kitchen/manager.rb +45 -0
- data/lib/kitchen/metadata_chopper.rb +52 -0
- data/lib/kitchen/platform.rb +61 -0
- data/lib/kitchen/rake_tasks.rb +59 -0
- data/lib/kitchen/shell_out.rb +65 -0
- data/lib/kitchen/state_file.rb +88 -0
- data/lib/kitchen/suite.rb +76 -0
- data/lib/kitchen/thor_tasks.rb +62 -0
- data/lib/kitchen/util.rb +79 -0
- data/{cookbooks/test-kitchen/recipes/erlang.rb → lib/kitchen/version.rb} +9 -6
- data/lib/kitchen.rb +98 -0
- data/lib/vendor/hash_recursive_merge.rb +74 -0
- data/spec/kitchen/collection_spec.rb +80 -0
- data/spec/kitchen/color_spec.rb +54 -0
- data/spec/kitchen/config_spec.rb +201 -0
- data/spec/kitchen/driver/dummy_spec.rb +191 -0
- data/spec/kitchen/instance_spec.rb +162 -0
- data/spec/kitchen/loader/yaml_spec.rb +243 -0
- data/spec/kitchen/platform_spec.rb +48 -0
- data/spec/kitchen/state_file_spec.rb +122 -0
- data/spec/kitchen/suite_spec.rb +64 -0
- data/spec/spec_helper.rb +47 -0
- data/templates/plugin/driver.rb.erb +23 -0
- data/templates/plugin/license_apachev2.erb +15 -0
- data/templates/plugin/license_gplv2.erb +18 -0
- data/templates/plugin/license_gplv3.erb +16 -0
- data/templates/plugin/license_mit.erb +22 -0
- data/templates/plugin/license_reserved.erb +5 -0
- data/templates/plugin/version.rb.erb +12 -0
- data/test-kitchen.gemspec +44 -0
- metadata +290 -82
- data/config/Cheffile +0 -47
- data/config/Kitchenfile +0 -39
- data/config/Vagrantfile +0 -114
- data/cookbooks/test-kitchen/attributes/default.rb +0 -25
- data/cookbooks/test-kitchen/metadata.rb +0 -27
- data/cookbooks/test-kitchen/recipes/chef.rb +0 -19
- data/cookbooks/test-kitchen/recipes/compat.rb +0 -39
- data/cookbooks/test-kitchen/recipes/default.rb +0 -51
- data/cookbooks/test-kitchen/recipes/ruby.rb +0 -29
- data/lib/test-kitchen/cli/destroy.rb +0 -36
- data/lib/test-kitchen/cli/init.rb +0 -37
- data/lib/test-kitchen/cli/platform_list.rb +0 -37
- data/lib/test-kitchen/cli/project_info.rb +0 -44
- data/lib/test-kitchen/cli/ssh.rb +0 -36
- data/lib/test-kitchen/cli/status.rb +0 -36
- data/lib/test-kitchen/cli/test.rb +0 -68
- data/lib/test-kitchen/cli.rb +0 -282
- data/lib/test-kitchen/dsl.rb +0 -63
- data/lib/test-kitchen/environment.rb +0 -166
- data/lib/test-kitchen/platform.rb +0 -79
- data/lib/test-kitchen/project/base.rb +0 -159
- data/lib/test-kitchen/project/cookbook.rb +0 -97
- data/lib/test-kitchen/project/cookbook_copy.rb +0 -58
- data/lib/test-kitchen/project/ruby.rb +0 -37
- data/lib/test-kitchen/project/supported_platforms.rb +0 -75
- data/lib/test-kitchen/project.rb +0 -23
- data/lib/test-kitchen/runner/base.rb +0 -154
- data/lib/test-kitchen/runner/openstack/dsl.rb +0 -39
- data/lib/test-kitchen/runner/openstack/environment.rb +0 -141
- data/lib/test-kitchen/runner/openstack.rb +0 -147
- data/lib/test-kitchen/runner/vagrant.rb +0 -95
- data/lib/test-kitchen/runner.rb +0 -21
- data/lib/test-kitchen/scaffold.rb +0 -88
- data/lib/test-kitchen/ui.rb +0 -73
- data/lib/test-kitchen/version.rb +0 -21
- data/lib/test-kitchen.rb +0 -34
@@ -0,0 +1,243 @@
|
|
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/util'
|
23
|
+
require 'kitchen/loader/yaml'
|
24
|
+
|
25
|
+
class Yamled
|
26
|
+
attr_accessor :foo
|
27
|
+
end
|
28
|
+
|
29
|
+
describe Kitchen::Loader::YAML do
|
30
|
+
|
31
|
+
let(:loader) { Kitchen::Loader::YAML.new("/tmp/.kitchen.yml") }
|
32
|
+
|
33
|
+
before do
|
34
|
+
FakeFS.activate!
|
35
|
+
FileUtils.mkdir_p("/tmp")
|
36
|
+
end
|
37
|
+
|
38
|
+
after do
|
39
|
+
FakeFS.deactivate!
|
40
|
+
FakeFS::FileSystem.clear
|
41
|
+
end
|
42
|
+
|
43
|
+
describe ".initialize" do
|
44
|
+
|
45
|
+
it "sets config_file based on Dir.pwd by default" do
|
46
|
+
loader = Kitchen::Loader::YAML.new
|
47
|
+
|
48
|
+
loader.config_file.must_equal File.expand_path(
|
49
|
+
File.join(Dir.pwd, '.kitchen.yml'))
|
50
|
+
end
|
51
|
+
|
52
|
+
it "sets config_file from parameter, if given" do
|
53
|
+
loader = Kitchen::Loader::YAML.new('/tmp/crazyfunkytown.file')
|
54
|
+
|
55
|
+
loader.config_file.must_equal '/tmp/crazyfunkytown.file'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#read" do
|
60
|
+
|
61
|
+
it "returns a hash of kitchen.yml with symbolized keys" do
|
62
|
+
stub_yaml!({
|
63
|
+
'foo' => 'bar'
|
64
|
+
})
|
65
|
+
|
66
|
+
loader.read.must_equal({ :foo => 'bar' })
|
67
|
+
end
|
68
|
+
|
69
|
+
it "deep merges in kitchen.local.yml configuration with kitchen.yml" do
|
70
|
+
stub_yaml!(".kitchen.yml", {
|
71
|
+
'common' => { 'xx' => 1 },
|
72
|
+
'a' => 'b'
|
73
|
+
})
|
74
|
+
stub_yaml!(".kitchen.local.yml", {
|
75
|
+
'common' => { 'yy' => 2 },
|
76
|
+
'c' => 'd'
|
77
|
+
})
|
78
|
+
|
79
|
+
loader.read.must_equal({
|
80
|
+
:a => 'b',
|
81
|
+
:c => 'd',
|
82
|
+
:common => { :xx => 1, :yy => 2 }
|
83
|
+
})
|
84
|
+
end
|
85
|
+
|
86
|
+
it "merges kitchen.local.yml over configuration in kitchen.yml" do
|
87
|
+
stub_yaml!(".kitchen.yml", {
|
88
|
+
'common' => { 'thekey' => 'nope' }
|
89
|
+
})
|
90
|
+
stub_yaml!(".kitchen.local.yml", {
|
91
|
+
'common' => { 'thekey' => 'yep' }
|
92
|
+
})
|
93
|
+
|
94
|
+
loader.read.must_equal({ :common => { :thekey => 'yep' } })
|
95
|
+
end
|
96
|
+
|
97
|
+
it "handles a kitchen.local.yml with no yaml elements" do
|
98
|
+
stub_yaml!(".kitchen.yml", {
|
99
|
+
'a' => 'b'
|
100
|
+
})
|
101
|
+
stub_yaml!(".kitchen.local.yml", Hash.new)
|
102
|
+
|
103
|
+
loader.read.must_equal({ :a => 'b' })
|
104
|
+
end
|
105
|
+
|
106
|
+
it "handles a kitchen.yml with no yaml elements" do
|
107
|
+
stub_yaml!(".kitchen.yml", Hash.new)
|
108
|
+
stub_yaml!(".kitchen.local.yml", {
|
109
|
+
'a' => 'b'
|
110
|
+
})
|
111
|
+
|
112
|
+
loader.read.must_equal({ :a => 'b' })
|
113
|
+
end
|
114
|
+
|
115
|
+
it "raises an UserError if the config_file does not exist" do
|
116
|
+
proc { loader.read }.must_raise Kitchen::UserError
|
117
|
+
end
|
118
|
+
|
119
|
+
it "arbitrary objects aren't deserialized in kitchen.yml" do
|
120
|
+
FileUtils.mkdir_p "/tmp"
|
121
|
+
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
122
|
+
f.write <<-YAML.gsub(/^ {10}/, '')
|
123
|
+
--- !ruby/object:Yamled
|
124
|
+
foo: bar
|
125
|
+
YAML
|
126
|
+
end
|
127
|
+
|
128
|
+
loader.read.class.wont_equal Yamled
|
129
|
+
loader.read.class.must_equal Hash
|
130
|
+
loader.read.must_equal({ :foo => 'bar' })
|
131
|
+
end
|
132
|
+
|
133
|
+
it "arbitrary objects aren't deserialized in kitchen.local.yml" do
|
134
|
+
FileUtils.mkdir_p "/tmp"
|
135
|
+
File.open("/tmp/.kitchen.local.yml", "wb") do |f|
|
136
|
+
f.write <<-YAML.gsub(/^ {10}/, '')
|
137
|
+
--- !ruby/object:Yamled
|
138
|
+
wakka: boop
|
139
|
+
YAML
|
140
|
+
end
|
141
|
+
stub_yaml!(".kitchen.yml", Hash.new)
|
142
|
+
|
143
|
+
loader.read.class.wont_equal Yamled
|
144
|
+
loader.read.class.must_equal Hash
|
145
|
+
loader.read.must_equal({ :wakka => 'boop' })
|
146
|
+
end
|
147
|
+
|
148
|
+
it "raises a UserError if kitchen.yml cannot be parsed" do
|
149
|
+
FileUtils.mkdir_p "/tmp"
|
150
|
+
File.open("/tmp/.kitchen.yml", "wb") { |f| f.write '&*%^*' }
|
151
|
+
|
152
|
+
proc { loader.read }.must_raise Kitchen::UserError
|
153
|
+
end
|
154
|
+
|
155
|
+
it "raises a UserError if kitchen.local.yml cannot be parsed" do
|
156
|
+
FileUtils.mkdir_p "/tmp"
|
157
|
+
File.open("/tmp/.kitchen.local.yml", "wb") { |f| f.write '&*%^*' }
|
158
|
+
stub_yaml!(".kitchen.yml", Hash.new)
|
159
|
+
|
160
|
+
proc { loader.read }.must_raise Kitchen::UserError
|
161
|
+
end
|
162
|
+
|
163
|
+
it "evaluates kitchen.yml through erb before loading by default" do
|
164
|
+
FileUtils.mkdir_p "/tmp"
|
165
|
+
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
166
|
+
f.write <<-'YAML'.gsub(/^ {10}/, '')
|
167
|
+
---
|
168
|
+
name: <%= "AHH".downcase + "choo" %>
|
169
|
+
YAML
|
170
|
+
end
|
171
|
+
|
172
|
+
loader.read.must_equal({ :name => "ahhchoo" })
|
173
|
+
end
|
174
|
+
|
175
|
+
it "evaluates kitchen.local.yml through erb before loading by default" do
|
176
|
+
FileUtils.mkdir_p "/tmp"
|
177
|
+
File.open("/tmp/.kitchen.local.yml", "wb") do |f|
|
178
|
+
f.write <<-'YAML'.gsub(/^ {10}/, '')
|
179
|
+
---
|
180
|
+
<% %w{noodle mushroom}.each do |kind| %>
|
181
|
+
<%= kind %>: soup
|
182
|
+
<% end %>
|
183
|
+
YAML
|
184
|
+
end
|
185
|
+
stub_yaml!(".kitchen.yml", { 'spinach' => 'salad' })
|
186
|
+
|
187
|
+
loader.read.must_equal({
|
188
|
+
:spinach => 'salad',
|
189
|
+
:noodle => 'soup',
|
190
|
+
:mushroom => 'soup'
|
191
|
+
})
|
192
|
+
end
|
193
|
+
|
194
|
+
it "skips evaluating kitchen.yml through erb if disabled" do
|
195
|
+
loader = Kitchen::Loader::YAML.new(
|
196
|
+
'/tmp/.kitchen.yml', :process_erb => false)
|
197
|
+
FileUtils.mkdir_p "/tmp"
|
198
|
+
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
199
|
+
f.write <<-'YAML'.gsub(/^ {10}/, '')
|
200
|
+
---
|
201
|
+
name: <%= "AHH".downcase %>
|
202
|
+
YAML
|
203
|
+
end
|
204
|
+
|
205
|
+
loader.read.must_equal({ :name => '<%= "AHH".downcase %>' })
|
206
|
+
end
|
207
|
+
|
208
|
+
it "skips evaluating kitchen.local.yml through erb if disabled" do
|
209
|
+
loader = Kitchen::Loader::YAML.new(
|
210
|
+
'/tmp/.kitchen.yml', :process_erb => false)
|
211
|
+
FileUtils.mkdir_p "/tmp"
|
212
|
+
File.open("/tmp/.kitchen.local.yml", "wb") do |f|
|
213
|
+
f.write <<-'YAML'.gsub(/^ {10}/, '')
|
214
|
+
---
|
215
|
+
name: <%= "AHH".downcase %>
|
216
|
+
YAML
|
217
|
+
end
|
218
|
+
stub_yaml!(".kitchen.yml", Hash.new)
|
219
|
+
|
220
|
+
loader.read.must_equal({ :name => '<%= "AHH".downcase %>' })
|
221
|
+
end
|
222
|
+
|
223
|
+
it "skips kitchen.local.yml if disabled" do
|
224
|
+
loader = Kitchen::Loader::YAML.new(
|
225
|
+
'/tmp/.kitchen.yml', :process_local => false)
|
226
|
+
stub_yaml!(".kitchen.yml", {
|
227
|
+
'a' => 'b'
|
228
|
+
})
|
229
|
+
stub_yaml!(".kitchen.local.yml", {
|
230
|
+
'superawesomesauceadditions' => 'enabled, yo'
|
231
|
+
})
|
232
|
+
|
233
|
+
loader.read.must_equal({ :a => 'b' })
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
private
|
238
|
+
|
239
|
+
def stub_yaml!(name = ".kitchen.yml", hash)
|
240
|
+
FileUtils.mkdir_p "/tmp"
|
241
|
+
File.open("/tmp/#{name}", "wb") { |f| f.write(hash.to_yaml) }
|
242
|
+
end
|
243
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2012, 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/platform'
|
23
|
+
|
24
|
+
describe Kitchen::Platform do
|
25
|
+
|
26
|
+
let(:opts) do ; { :name => 'plata' } ; end
|
27
|
+
let(:platform) { Kitchen::Platform.new(opts) }
|
28
|
+
|
29
|
+
it "raises an ArgumentError if name is missing" do
|
30
|
+
opts.delete(:name)
|
31
|
+
proc { Kitchen::Platform.new(opts) }.must_raise Kitchen::ClientError
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns an empty Array given no run_list" do
|
35
|
+
platform.run_list.must_equal []
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns an empty Hash given no attributes" do
|
39
|
+
platform.attributes.must_equal Hash.new
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns attributes from constructor" do
|
43
|
+
opts.merge!({ :run_list => ['a', 'b'], :attributes => { :c => 'd' } })
|
44
|
+
platform.name.must_equal 'plata'
|
45
|
+
platform.run_list.must_equal ['a', 'b']
|
46
|
+
platform.attributes.must_equal({ :c => 'd' })
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,122 @@
|
|
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/state_file'
|
23
|
+
require 'kitchen/util'
|
24
|
+
|
25
|
+
class YamledState
|
26
|
+
attr_accessor :yoinks
|
27
|
+
end
|
28
|
+
|
29
|
+
describe Kitchen::StateFile do
|
30
|
+
|
31
|
+
let(:state_file) { Kitchen::StateFile.new('/tmp', 'oftheunion')}
|
32
|
+
let(:file_name) { '/tmp/.kitchen/oftheunion.yml' }
|
33
|
+
|
34
|
+
before do
|
35
|
+
FakeFS.activate!
|
36
|
+
FileUtils.mkdir_p("/tmp")
|
37
|
+
end
|
38
|
+
|
39
|
+
after do
|
40
|
+
FakeFS.deactivate!
|
41
|
+
FakeFS::FileSystem.clear
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#read" do
|
45
|
+
|
46
|
+
it "returns an empty hash if the file does not exist" do
|
47
|
+
state_file.read.must_equal(Hash.new)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns a Hash with symbolized keys from the state file" do
|
51
|
+
stub_state_file!
|
52
|
+
|
53
|
+
state_file.read.must_equal({
|
54
|
+
:cloud_id => 42,
|
55
|
+
:flavor => 'extra_crispy'
|
56
|
+
})
|
57
|
+
end
|
58
|
+
|
59
|
+
it "arbitrary objects aren't deserialized from state file" do
|
60
|
+
stub_state_file! <<-'YAML'.gsub(/^ {8}/, '')
|
61
|
+
--- !ruby/object:YamledState
|
62
|
+
yoinks: zoinks
|
63
|
+
YAML
|
64
|
+
|
65
|
+
state_file.read.class.wont_equal YamledState
|
66
|
+
state_file.read.class.must_equal Hash
|
67
|
+
state_file.read.must_equal({ :yoinks => 'zoinks' })
|
68
|
+
end
|
69
|
+
|
70
|
+
it "raises a StateFileLoadError if the state file cannot be parsed" do
|
71
|
+
stub_state_file!('&*%^*')
|
72
|
+
|
73
|
+
proc { state_file.read }.must_raise Kitchen::StateFileLoadError
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#write" do
|
78
|
+
|
79
|
+
it "creates the directory path to the state file" do
|
80
|
+
File.directory?('/tmp/.kitchen').must_equal false
|
81
|
+
state_file.write({})
|
82
|
+
File.directory?('/tmp/.kitchen').must_equal true
|
83
|
+
end
|
84
|
+
|
85
|
+
it "writes a state file with stringified keys" do
|
86
|
+
state_file.write({ :thekey => 'thyself' })
|
87
|
+
|
88
|
+
IO.read(file_name).split("\n").must_include 'thekey: thyself'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#destroy" do
|
93
|
+
|
94
|
+
it "executes if no file exists" do
|
95
|
+
File.exists?(file_name).must_equal false
|
96
|
+
state_file.destroy
|
97
|
+
File.exists?(file_name).must_equal false
|
98
|
+
end
|
99
|
+
|
100
|
+
it "deletes the state file" do
|
101
|
+
stub_state_file!
|
102
|
+
state_file.destroy
|
103
|
+
|
104
|
+
File.exists?(file_name).must_equal false
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def stub_state_file!(yaml_string = nil)
|
111
|
+
if yaml_string.nil?
|
112
|
+
yaml_string = <<-'YAML'.gsub(/^ {8}/, '')
|
113
|
+
---
|
114
|
+
cloud_id: 42
|
115
|
+
flavor: extra_crispy
|
116
|
+
YAML
|
117
|
+
end
|
118
|
+
|
119
|
+
FileUtils.mkdir_p(File.dirname(file_name))
|
120
|
+
File.open(file_name, 'wb') { |f| f.write(yaml_string) }
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2012, 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/suite'
|
23
|
+
|
24
|
+
describe Kitchen::Suite do
|
25
|
+
|
26
|
+
let(:opts) do ; { :name => 'suitezy', :run_list => ['doowah'] } ; end
|
27
|
+
let(:suite) { Kitchen::Suite.new(opts) }
|
28
|
+
|
29
|
+
it "raises an ArgumentError if name is missing" do
|
30
|
+
opts.delete(:name)
|
31
|
+
proc { Kitchen::Suite.new(opts) }.must_raise Kitchen::ClientError
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises an ArgumentError if run_list is missing" do
|
35
|
+
opts.delete(:run_list)
|
36
|
+
proc { Kitchen::Suite.new(opts) }.must_raise Kitchen::ClientError
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns an empty Hash given no attributes" do
|
40
|
+
suite.attributes.must_equal Hash.new
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns an empty Array given no excludes" do
|
44
|
+
suite.excludes.must_equal Array.new
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns nil given no data_bags_path" do
|
48
|
+
suite.data_bags_path.must_be_nil
|
49
|
+
end
|
50
|
+
|
51
|
+
it "returns nil given no roles_path" do
|
52
|
+
suite.roles_path.must_be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns attributes from constructor" do
|
56
|
+
opts.merge!({ :attributes => { :a => 'b' }, :data_bags_path => 'crazy',
|
57
|
+
:roles_path => 'town' })
|
58
|
+
suite.name.must_equal 'suitezy'
|
59
|
+
suite.run_list.must_equal ['doowah']
|
60
|
+
suite.attributes.must_equal({ :a => 'b' })
|
61
|
+
suite.data_bags_path.must_equal 'crazy'
|
62
|
+
suite.roles_path.must_equal 'town'
|
63
|
+
end
|
64
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2012, 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 'simplecov'
|
20
|
+
SimpleCov.adapters.define 'gem' do
|
21
|
+
command_name 'Specs'
|
22
|
+
|
23
|
+
add_filter '.gem/'
|
24
|
+
add_filter '/spec/'
|
25
|
+
add_filter '/lib/vendor/'
|
26
|
+
|
27
|
+
add_group 'Libraries', '/lib/'
|
28
|
+
end
|
29
|
+
SimpleCov.start 'gem'
|
30
|
+
|
31
|
+
require 'fakefs/safe'
|
32
|
+
require 'minitest/autorun'
|
33
|
+
require 'mocha/setup'
|
34
|
+
|
35
|
+
# enable yaml symbol parsing if code is executing under guard
|
36
|
+
if ENV['GUARD_NOTIFY']
|
37
|
+
require 'safe_yaml'
|
38
|
+
YAML.enable_symbol_parsing!
|
39
|
+
SafeYAML::OPTIONS[:suppress_warnings] = true
|
40
|
+
end
|
41
|
+
|
42
|
+
# Nasty hack to redefine IO.read in terms of File#read for fakefs
|
43
|
+
class IO
|
44
|
+
def self.read(*args)
|
45
|
+
File.open(args[0], "rb") { |f| f.read(args[1]) }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
<%= license %>
|
4
|
+
|
5
|
+
require 'kitchen'
|
6
|
+
|
7
|
+
module Kitchen
|
8
|
+
|
9
|
+
module Driver
|
10
|
+
|
11
|
+
# <%= klass_name %> driver for Kitchen.
|
12
|
+
#
|
13
|
+
# @author <%= author %> <<%= email %>>
|
14
|
+
class <%= klass_name %> < Kitchen::Driver::SSHBase
|
15
|
+
|
16
|
+
def create(state)
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy(state)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Author:: <%= author %> (<<%= email %>>)
|
2
|
+
|
3
|
+
Copyright (C) <%= year %>, <%= author %>
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Author:: <%= author %> (<<%= email %>>)
|
2
|
+
|
3
|
+
Copyright (C) <%= year %> <%= author %>
|
4
|
+
|
5
|
+
This program is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU General Public License
|
7
|
+
as published by the Free Software Foundation; either version 2
|
8
|
+
of the License, or (at your option) any later version.
|
9
|
+
|
10
|
+
This program is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
GNU General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU General Public License
|
16
|
+
along with this program; if not, write to the Free Software
|
17
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
18
|
+
Boston, MA 02110-1301, USA.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Author:: <%= author %> (<<%= email %>>)
|
2
|
+
|
3
|
+
Copyright (C) <%= year %> <%= author %>
|
4
|
+
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
6
|
+
it under the terms of the GNU General Public License as published by
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
8
|
+
(at your option) any later version.
|
9
|
+
|
10
|
+
This program is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
GNU General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU General Public License
|
16
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Author:: <%= author %> (<<%= email %>>)
|
2
|
+
|
3
|
+
Copyright (c) <%= year %>, <%= author %>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kitchen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "test-kitchen"
|
8
|
+
gem.version = Kitchen::VERSION
|
9
|
+
gem.license = 'Apache 2.0'
|
10
|
+
gem.authors = ["Fletcher Nichol"]
|
11
|
+
gem.email = ["fnichol@nichol.ca"]
|
12
|
+
gem.description = %q{A Chef convergence integration test harness}
|
13
|
+
gem.summary = gem.description
|
14
|
+
gem.homepage = "https://github.com/opscode/test-kitchen"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = %w(kitchen)
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.required_ruby_version = ">= 1.9.1"
|
22
|
+
|
23
|
+
gem.add_dependency 'celluloid'
|
24
|
+
gem.add_dependency 'thor'
|
25
|
+
gem.add_dependency 'pry'
|
26
|
+
gem.add_dependency 'net-ssh'
|
27
|
+
gem.add_dependency 'net-scp'
|
28
|
+
gem.add_dependency 'mixlib-shellout'
|
29
|
+
gem.add_dependency 'safe_yaml'
|
30
|
+
|
31
|
+
gem.add_development_dependency 'minitest'
|
32
|
+
gem.add_development_dependency 'mocha'
|
33
|
+
gem.add_development_dependency 'fakefs'
|
34
|
+
gem.add_development_dependency 'guard-minitest'
|
35
|
+
gem.add_development_dependency 'aruba', '~> 0.5'
|
36
|
+
gem.add_development_dependency 'guard-cucumber'
|
37
|
+
|
38
|
+
gem.add_development_dependency 'yard'
|
39
|
+
gem.add_development_dependency 'maruku'
|
40
|
+
gem.add_development_dependency 'cane'
|
41
|
+
gem.add_development_dependency 'tailor'
|
42
|
+
gem.add_development_dependency 'simplecov'
|
43
|
+
gem.add_development_dependency 'countloc'
|
44
|
+
end
|