chef 12.0.0.alpha.0 → 12.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +3 -5
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +16 -8
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +3 -3
- data/lib/chef/chef_fs/file_system/cookbook_file.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -4
- data/lib/chef/config.rb +6 -5
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +126 -43
- data/lib/chef/cookbook/metadata.rb +102 -53
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_loader.rb +62 -14
- data/lib/chef/cookbook_site_streaming_uploader.rb +12 -1
- data/lib/chef/cookbook_version.rb +13 -4
- data/lib/chef/data_bag.rb +28 -15
- data/lib/chef/data_bag_item.rb +5 -7
- data/lib/chef/digester.rb +5 -9
- data/lib/chef/dsl/recipe.rb +14 -0
- data/lib/chef/encrypted_data_bag_item.rb +1 -0
- data/lib/chef/encrypted_data_bag_item/assertions.rb +57 -0
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +52 -28
- data/lib/chef/encrypted_data_bag_item/encrypted_data_bag_item_assertions.rb +37 -0
- data/lib/chef/encrypted_data_bag_item/encryption_failure.rb +22 -0
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +79 -8
- data/lib/chef/environment.rb +1 -3
- data/lib/chef/exceptions.rb +18 -3
- data/lib/chef/formatters/base.rb +7 -0
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +1 -1
- data/lib/chef/handler/json_file.rb +0 -1
- data/lib/chef/http/json_output.rb +1 -1
- data/lib/chef/json_compat.rb +24 -6
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/client_delete.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_list.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +2 -2
- data/lib/chef/knife/cookbook_site_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/core/node_editor.rb +2 -3
- data/lib/chef/knife/core/ui.rb +2 -2
- data/lib/chef/knife/deps.rb +2 -3
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/mixin/windows_architecture_helper.rb +1 -0
- data/lib/chef/node.rb +1 -2
- data/lib/chef/platform/provider_mapping.rb +33 -6
- data/lib/chef/provider.rb +0 -2
- data/lib/chef/provider/cookbook_file/content.rb +1 -1
- data/lib/chef/provider/cron.rb +11 -0
- data/lib/chef/provider/deploy.rb +3 -2
- data/lib/chef/provider/deploy/revision.rb +2 -2
- data/lib/chef/provider/env.rb +1 -1
- data/lib/chef/provider/env/windows.rb +5 -9
- data/lib/chef/provider/file.rb +84 -33
- data/lib/chef/provider/git.rb +2 -1
- data/lib/chef/provider/group/aix.rb +17 -2
- data/lib/chef/provider/group/dscl.rb +27 -9
- data/lib/chef/provider/group/pw.rb +8 -1
- data/lib/chef/provider/http_request.rb +4 -4
- data/lib/chef/provider/log.rb +4 -14
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/package/ips.rb +17 -23
- data/lib/chef/provider/package/paludis.rb +2 -2
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +2 -0
- data/lib/chef/provider/package/yum.rb +2 -0
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/remote_file/cache_control_data.rb +2 -2
- data/lib/chef/provider/service/windows.rb +87 -21
- data/lib/chef/provider/user/aix.rb +95 -0
- data/lib/chef/provider/user/dscl.rb +544 -156
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +4 -3
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/paludis_package.rb +1 -0
- data/lib/chef/resource/scm.rb +10 -0
- data/lib/chef/resource/user.rb +27 -0
- data/lib/chef/resource/windows_service.rb +53 -0
- data/lib/chef/resource_collection.rb +23 -12
- data/lib/chef/resource_reporter.rb +10 -10
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/role.rb +3 -3
- data/lib/chef/run_list.rb +6 -3
- data/lib/chef/user.rb +1 -1
- data/lib/chef/util/diff.rb +1 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_constraint.rb +4 -4
- data/spec/data/cookbooks/angrybash/metadata.rb +2 -0
- data/spec/data/cookbooks/apache2/metadata.rb +2 -0
- data/spec/data/cookbooks/borken/metadata.rb +2 -0
- data/spec/data/cookbooks/ignorken/metadata.rb +2 -0
- data/spec/data/cookbooks/java/metadata.rb +2 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/README.md +4 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/metadata.rb +8 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/recipes/default.rb +8 -0
- data/spec/data/cookbooks/openldap/files/default/remotedir/not_a_template.erb +2 -0
- data/spec/data/cookbooks/preseed/metadata.rb +2 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/README.md +4 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/metadata.rb +13 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/recipes/default.rb +8 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/README.md +4 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/metadata.rb +10 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/recipes/default.rb +8 -0
- data/spec/data/mac_users/10.7-8.plist.xml +559 -0
- data/spec/data/mac_users/10.7-8.shadow.xml +11 -0
- data/spec/data/mac_users/10.7.plist.xml +559 -0
- data/spec/data/mac_users/10.7.shadow.xml +11 -0
- data/spec/data/mac_users/10.8.plist.xml +559 -0
- data/spec/data/mac_users/10.8.shadow.xml +21 -0
- data/spec/data/mac_users/10.9.plist.xml +560 -0
- data/spec/data/mac_users/10.9.shadow.xml +21 -0
- data/spec/data/object_loader/environments/test.json +2 -0
- data/spec/data/object_loader/environments/test_json_class.json +2 -0
- data/spec/data/object_loader/nodes/test.json +2 -0
- data/spec/data/object_loader/nodes/test_json_class.json +2 -0
- data/spec/data/object_loader/roles/test.json +2 -0
- data/spec/data/object_loader/roles/test_json_class.json +2 -0
- data/spec/functional/resource/bff_spec.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +20 -1
- data/spec/functional/resource/env_spec.rb +137 -0
- data/spec/functional/resource/group_spec.rb +7 -5
- data/spec/functional/resource/remote_file_spec.rb +12 -1
- data/spec/functional/resource/user/dscl_spec.rb +198 -0
- data/spec/functional/resource/{user_spec.rb → user/useradd_spec.rb} +175 -37
- data/spec/integration/client/client_spec.rb +6 -4
- data/spec/integration/client/ipv6_spec.rb +16 -14
- data/spec/integration/knife/chef_fs_data_store_spec.rb +57 -46
- data/spec/integration/knife/chef_repo_path_spec.rb +105 -78
- data/spec/integration/knife/chef_repository_file_system_spec.rb +100 -84
- data/spec/integration/knife/chefignore_spec.rb +76 -46
- data/spec/integration/knife/common_options_spec.rb +16 -21
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +3 -3
- data/spec/integration/knife/delete_spec.rb +66 -46
- data/spec/integration/knife/deps_spec.rb +145 -94
- data/spec/integration/knife/diff_spec.rb +176 -110
- data/spec/integration/knife/download_spec.rb +229 -133
- data/spec/integration/knife/list_spec.rb +62 -54
- data/spec/integration/knife/raw_spec.rb +24 -9
- data/spec/integration/knife/redirection_spec.rb +2 -2
- data/spec/integration/knife/serve_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +32 -26
- data/spec/integration/knife/upload_spec.rb +308 -165
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +10 -8
- data/spec/integration/solo/solo_spec.rb +22 -11
- data/spec/spec_helper.rb +3 -0
- data/spec/support/lib/chef/resource/zen_follower.rb +46 -0
- data/spec/support/platform_helpers.rb +12 -0
- data/spec/support/shared/functional/file_resource.rb +10 -0
- data/spec/support/shared/integration/chef_zero_support.rb +130 -0
- data/spec/support/shared/integration/integration_helper.rb +100 -98
- data/spec/support/shared/integration/knife_support.rb +0 -1
- data/spec/support/shared/unit/provider/file.rb +6 -4
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +10 -1
- data/spec/unit/api_client/registration_spec.rb +83 -74
- data/spec/unit/application_spec.rb +32 -9
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +179 -0
- data/spec/unit/cookbook/metadata_spec.rb +190 -150
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -2
- data/spec/unit/cookbook_loader_spec.rb +114 -53
- data/spec/unit/{cookbook_site_streaming_uploader.rb → cookbook_site_streaming_uploader_spec.rb} +21 -1
- data/spec/unit/data_bag_spec.rb +88 -13
- data/spec/unit/deprecation_spec.rb +1 -2
- data/spec/unit/encrypted_data_bag_item_spec.rb +145 -9
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/formatters/base_spec.rb +48 -0
- data/spec/unit/json_compat_spec.rb +48 -17
- data/spec/unit/knife/client_delete_spec.rb +4 -4
- data/spec/unit/knife/client_show_spec.rb +15 -5
- data/spec/unit/knife/cookbook_site_download_spec.rb +1 -1
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/data_bag_from_file_spec.rb +0 -2
- data/spec/unit/knife/data_bag_show_spec.rb +23 -14
- data/spec/unit/knife/node_show_spec.rb +32 -15
- data/spec/unit/knife/role_show_spec.rb +59 -0
- data/spec/unit/platform_spec.rb +10 -0
- data/spec/unit/provider/deploy_spec.rb +4 -0
- data/spec/unit/provider/env_spec.rb +19 -0
- data/spec/unit/provider/git_spec.rb +22 -2
- data/spec/unit/provider/group/dscl_spec.rb +38 -1
- data/spec/unit/provider/group/pw_spec.rb +2 -2
- data/spec/unit/provider/http_request_spec.rb +8 -8
- data/spec/unit/provider/log_spec.rb +33 -53
- data/spec/unit/provider/mount/mount_spec.rb +12 -3
- data/spec/unit/provider/package/ips_spec.rb +96 -63
- data/spec/unit/provider/package/paludis_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +12 -0
- data/spec/unit/provider/package/zypper_spec.rb +28 -16
- data/spec/unit/provider/service/windows_spec.rb +77 -17
- data/spec/unit/provider/user/dscl_spec.rb +659 -264
- data/spec/unit/provider/user/useradd_spec.rb +1 -0
- data/spec/unit/recipe_spec.rb +41 -0
- data/spec/unit/resource/scm_spec.rb +11 -0
- data/spec/unit/resource/user_spec.rb +4 -0
- data/spec/unit/resource/windows_service_spec.rb +46 -0
- data/spec/unit/resource_collection_spec.rb +33 -0
- data/spec/unit/resource_reporter_spec.rb +48 -0
- data/spec/unit/resource_spec.rb +9 -2
- data/spec/unit/role_spec.rb +6 -0
- data/spec/unit/version_constraint_spec.rb +28 -0
- metadata +61 -4
@@ -21,10 +21,8 @@ require 'spec_helper'
|
|
21
21
|
require 'chef/cookbook/metadata'
|
22
22
|
|
23
23
|
describe Chef::Cookbook::Metadata do
|
24
|
-
|
25
|
-
|
26
|
-
@meta = Chef::Cookbook::Metadata.new(@cookbook)
|
27
|
-
end
|
24
|
+
|
25
|
+
let(:metadata) { Chef::Cookbook::Metadata.new }
|
28
26
|
|
29
27
|
describe "when comparing for equality" do
|
30
28
|
before do
|
@@ -35,7 +33,7 @@ describe Chef::Cookbook::Metadata do
|
|
35
33
|
end
|
36
34
|
|
37
35
|
it "does not depend on object identity for equality" do
|
38
|
-
|
36
|
+
metadata.should == metadata.dup
|
39
37
|
end
|
40
38
|
|
41
39
|
it "is not equal to another object if it isn't have all of the metadata fields" do
|
@@ -45,7 +43,7 @@ describe Chef::Cookbook::Metadata do
|
|
45
43
|
almost_duck_type = Struct.new(*fields_to_include).new
|
46
44
|
@fields.each do |field|
|
47
45
|
setter = "#{field}="
|
48
|
-
metadata_value =
|
46
|
+
metadata_value = metadata.send(field)
|
49
47
|
almost_duck_type.send(setter, metadata_value) if almost_duck_type.respond_to?(setter)
|
50
48
|
@mets.should_not == almost_duck_type
|
51
49
|
end
|
@@ -56,10 +54,10 @@ describe Chef::Cookbook::Metadata do
|
|
56
54
|
duck_type = Struct.new(*@fields).new
|
57
55
|
@fields.each do |field|
|
58
56
|
setter = "#{field}="
|
59
|
-
metadata_value =
|
57
|
+
metadata_value = metadata.send(field)
|
60
58
|
duck_type.send(setter, metadata_value)
|
61
59
|
end
|
62
|
-
|
60
|
+
metadata.should == duck_type
|
63
61
|
end
|
64
62
|
|
65
63
|
it "is not equal if any values are different" do
|
@@ -69,78 +67,117 @@ describe Chef::Cookbook::Metadata do
|
|
69
67
|
|
70
68
|
@fields.each do |field|
|
71
69
|
setter = "#{field}="
|
72
|
-
metadata_value =
|
70
|
+
metadata_value = metadata.send(field)
|
73
71
|
duck_type.send(setter, metadata_value)
|
74
72
|
end
|
75
73
|
|
76
|
-
field_to_change
|
77
|
-
|
78
74
|
duck_type.send("#{field_to_change}=".to_sym, :epic_fail)
|
79
|
-
|
75
|
+
metadata.should_not == duck_type
|
80
76
|
end
|
81
77
|
end
|
82
78
|
|
83
79
|
end
|
84
80
|
|
85
81
|
describe "when first created" do
|
86
|
-
|
87
|
-
|
82
|
+
|
83
|
+
it "has no name" do
|
84
|
+
metadata.name.should eq(nil)
|
88
85
|
end
|
89
86
|
|
90
|
-
it "
|
91
|
-
|
87
|
+
it "has an empty description" do
|
88
|
+
metadata.description.should eq("")
|
92
89
|
end
|
93
90
|
|
94
|
-
it "
|
95
|
-
|
91
|
+
it "has an empty long description" do
|
92
|
+
metadata.long_description.should eq("")
|
96
93
|
end
|
97
94
|
|
98
|
-
it "
|
99
|
-
|
100
|
-
md.maintainer.should == 'Bobo T. Clown'
|
95
|
+
it "defaults to 'all rights reserved' license" do
|
96
|
+
metadata.license.should eq("All rights reserved")
|
101
97
|
end
|
102
98
|
|
103
|
-
it "
|
104
|
-
|
99
|
+
it "has an empty maintainer field" do
|
100
|
+
metadata.maintainer.should eq(nil)
|
105
101
|
end
|
106
102
|
|
107
|
-
it "
|
108
|
-
|
109
|
-
md.maintainer_email.should == 'bobo@clown.co'
|
103
|
+
it "has an empty maintainer_email field" do
|
104
|
+
metadata.maintainer.should eq(nil)
|
110
105
|
end
|
111
106
|
|
112
|
-
it "
|
113
|
-
|
107
|
+
it "has an empty platforms list" do
|
108
|
+
metadata.platforms.should eq(Mash.new)
|
114
109
|
end
|
115
110
|
|
116
|
-
it "
|
117
|
-
|
118
|
-
md.license.should == 'Clown License v1'
|
111
|
+
it "has an empty dependencies list" do
|
112
|
+
metadata.dependencies.should eq(Mash.new)
|
119
113
|
end
|
120
|
-
end
|
121
114
|
|
122
|
-
|
123
|
-
|
124
|
-
@meta.cookbook.should eql(@cookbook)
|
115
|
+
it "has an empty recommends list" do
|
116
|
+
metadata.recommendations.should eq(Mash.new)
|
125
117
|
end
|
126
|
-
end
|
127
118
|
|
128
|
-
|
129
|
-
|
130
|
-
@meta.name.should eql(@cookbook.name)
|
119
|
+
it "has an empty suggestions list" do
|
120
|
+
metadata.suggestions.should eq(Mash.new)
|
131
121
|
end
|
122
|
+
|
123
|
+
it "has an empty conflicts list" do
|
124
|
+
metadata.conflicting.should eq(Mash.new)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "has an empty replaces list" do
|
128
|
+
metadata.replacing.should eq(Mash.new)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "has an empty attributes list" do
|
132
|
+
metadata.attributes.should eq(Mash.new)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "has an empty groupings list" do
|
136
|
+
metadata.groupings.should eq(Mash.new)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "has an empty recipes list" do
|
140
|
+
metadata.recipes.should eq(Mash.new)
|
141
|
+
end
|
142
|
+
|
132
143
|
end
|
133
144
|
|
134
|
-
describe "
|
135
|
-
|
136
|
-
|
145
|
+
describe "validation" do
|
146
|
+
|
147
|
+
context "when no required fields are set" do
|
148
|
+
|
149
|
+
it "is not valid" do
|
150
|
+
metadata.should_not be_valid
|
151
|
+
end
|
152
|
+
|
153
|
+
it "has a list of validation errors" do
|
154
|
+
expected_errors = ["The `name' attribute is required in cookbook metadata"]
|
155
|
+
metadata.errors.should eq(expected_errors)
|
156
|
+
end
|
157
|
+
|
137
158
|
end
|
159
|
+
|
160
|
+
context "when all required fields are set" do
|
161
|
+
before do
|
162
|
+
metadata.name "a-valid-name"
|
163
|
+
end
|
164
|
+
|
165
|
+
it "is valid" do
|
166
|
+
metadata.should be_valid
|
167
|
+
end
|
168
|
+
|
169
|
+
it "has no validation errors" do
|
170
|
+
metadata.errors.should be_empty
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
138
175
|
end
|
139
176
|
|
140
177
|
describe "adding a supported platform" do
|
141
178
|
it "should support adding a supported platform with a single expression" do
|
142
|
-
|
143
|
-
|
179
|
+
metadata.supports("ubuntu", ">= 8.04")
|
180
|
+
metadata.platforms["ubuntu"].should == '>= 8.04'
|
144
181
|
end
|
145
182
|
end
|
146
183
|
|
@@ -156,23 +193,23 @@ describe Chef::Cookbook::Metadata do
|
|
156
193
|
params.sort { |a,b| a.to_s <=> b.to_s }.each do |field, field_value|
|
157
194
|
describe field do
|
158
195
|
it "should be set-able via #{field}" do
|
159
|
-
|
196
|
+
metadata.send(field, field_value).should eql(field_value)
|
160
197
|
end
|
161
198
|
it "should be get-able via #{field}" do
|
162
|
-
|
163
|
-
|
199
|
+
metadata.send(field, field_value)
|
200
|
+
metadata.send(field).should eql(field_value)
|
164
201
|
end
|
165
202
|
end
|
166
203
|
end
|
167
204
|
|
168
205
|
describe "version transformation" do
|
169
206
|
it "should transform an '0.6' version to '0.6.0'" do
|
170
|
-
|
207
|
+
metadata.send(:version, "0.6").should eql("0.6.0")
|
171
208
|
end
|
172
209
|
|
173
210
|
it "should spit out '0.6.0' after transforming '0.6'" do
|
174
|
-
|
175
|
-
|
211
|
+
metadata.send(:version, "0.6")
|
212
|
+
metadata.send(:version).should eql("0.6.0")
|
176
213
|
end
|
177
214
|
end
|
178
215
|
end
|
@@ -191,11 +228,11 @@ describe Chef::Cookbook::Metadata do
|
|
191
228
|
check_with = dep_args.shift
|
192
229
|
describe dep do
|
193
230
|
it "should be set-able via #{dep}" do
|
194
|
-
|
231
|
+
metadata.send(dep, *dep_args).should == dep_args[1]
|
195
232
|
end
|
196
233
|
it "should be get-able via #{check_with}" do
|
197
|
-
|
198
|
-
|
234
|
+
metadata.send(dep, *dep_args)
|
235
|
+
metadata.send(check_with).should == { dep_args[0] => dep_args[1] }
|
199
236
|
end
|
200
237
|
end
|
201
238
|
end
|
@@ -213,11 +250,11 @@ describe Chef::Cookbook::Metadata do
|
|
213
250
|
normalized_version = dep_args.pop
|
214
251
|
describe dep do
|
215
252
|
it "should be set-able and normalized via #{dep}" do
|
216
|
-
|
253
|
+
metadata.send(dep, *dep_args).should == normalized_version
|
217
254
|
end
|
218
255
|
it "should be get-able and normalized via #{check_with}" do
|
219
|
-
|
220
|
-
|
256
|
+
metadata.send(dep, *dep_args)
|
257
|
+
metadata.send(check_with).should == { dep_args[0] => normalized_version }
|
221
258
|
end
|
222
259
|
end
|
223
260
|
end
|
@@ -235,7 +272,7 @@ describe Chef::Cookbook::Metadata do
|
|
235
272
|
|
236
273
|
dep_types.each do |dep, dep_args|
|
237
274
|
it "for #{dep} raises an informative error instead of vomiting on your shoes" do
|
238
|
-
lambda {
|
275
|
+
lambda {metadata.send(dep, *dep_args)}.should raise_error(Chef::Exceptions::ObsoleteDependencySyntax)
|
239
276
|
end
|
240
277
|
end
|
241
278
|
end
|
@@ -253,7 +290,7 @@ describe Chef::Cookbook::Metadata do
|
|
253
290
|
|
254
291
|
dep_types.each do |dep, dep_args|
|
255
292
|
it "for #{dep} raises an informative error instead of vomiting on your shoes" do
|
256
|
-
lambda {
|
293
|
+
lambda {metadata.send(dep, *dep_args)}.should raise_error(Chef::Exceptions::InvalidVersionConstraint)
|
257
294
|
end
|
258
295
|
end
|
259
296
|
end
|
@@ -265,23 +302,23 @@ describe Chef::Cookbook::Metadata do
|
|
265
302
|
"title" => "MySQL Tuning",
|
266
303
|
"description" => "Setting from the my.cnf file that allow you to tune your mysql server"
|
267
304
|
}
|
268
|
-
|
305
|
+
metadata.grouping("/db/mysql/databases/tuning", group).should == group
|
269
306
|
end
|
270
307
|
it "should not accept anything but a string for display_name" do
|
271
308
|
lambda {
|
272
|
-
|
309
|
+
metadata.grouping("db/mysql/databases", :title => "foo")
|
273
310
|
}.should_not raise_error
|
274
311
|
lambda {
|
275
|
-
|
312
|
+
metadata.grouping("db/mysql/databases", :title => Hash.new)
|
276
313
|
}.should raise_error(ArgumentError)
|
277
314
|
end
|
278
315
|
|
279
316
|
it "should not accept anything but a string for the description" do
|
280
317
|
lambda {
|
281
|
-
|
318
|
+
metadata.grouping("db/mysql/databases", :description => "foo")
|
282
319
|
}.should_not raise_error
|
283
320
|
lambda {
|
284
|
-
|
321
|
+
metadata.grouping("db/mysql/databases", :description => Hash.new)
|
285
322
|
}.should raise_error(ArgumentError)
|
286
323
|
end
|
287
324
|
end
|
@@ -298,151 +335,151 @@ describe Chef::Cookbook::Metadata do
|
|
298
335
|
"recipes" => [ "mysql::server", "mysql::master" ],
|
299
336
|
"default" => [ ]
|
300
337
|
}
|
301
|
-
|
338
|
+
metadata.attribute("/db/mysql/databases", attrs).should == attrs
|
302
339
|
end
|
303
340
|
|
304
341
|
it "should not accept anything but a string for display_name" do
|
305
342
|
lambda {
|
306
|
-
|
343
|
+
metadata.attribute("db/mysql/databases", :display_name => "foo")
|
307
344
|
}.should_not raise_error
|
308
345
|
lambda {
|
309
|
-
|
346
|
+
metadata.attribute("db/mysql/databases", :display_name => Hash.new)
|
310
347
|
}.should raise_error(ArgumentError)
|
311
348
|
end
|
312
349
|
|
313
350
|
it "should not accept anything but a string for the description" do
|
314
351
|
lambda {
|
315
|
-
|
352
|
+
metadata.attribute("db/mysql/databases", :description => "foo")
|
316
353
|
}.should_not raise_error
|
317
354
|
lambda {
|
318
|
-
|
355
|
+
metadata.attribute("db/mysql/databases", :description => Hash.new)
|
319
356
|
}.should raise_error(ArgumentError)
|
320
357
|
end
|
321
358
|
|
322
359
|
it "should not accept anything but an array of strings for choice" do
|
323
360
|
lambda {
|
324
|
-
|
361
|
+
metadata.attribute("db/mysql/databases", :choice => ['dedicated', 'shared'])
|
325
362
|
}.should_not raise_error
|
326
363
|
lambda {
|
327
|
-
|
364
|
+
metadata.attribute("db/mysql/databases", :choice => [10, 'shared'])
|
328
365
|
}.should raise_error(ArgumentError)
|
329
366
|
lambda {
|
330
|
-
|
367
|
+
metadata.attribute("db/mysql/databases", :choice => Hash.new)
|
331
368
|
}.should raise_error(ArgumentError)
|
332
369
|
end
|
333
370
|
|
334
371
|
it "should set choice to empty array by default" do
|
335
|
-
|
336
|
-
|
372
|
+
metadata.attribute("db/mysql/databases", {})
|
373
|
+
metadata.attributes["db/mysql/databases"][:choice].should == []
|
337
374
|
end
|
338
375
|
|
339
376
|
it "should let calculated be true or false" do
|
340
377
|
lambda {
|
341
|
-
|
378
|
+
metadata.attribute("db/mysql/databases", :calculated => true)
|
342
379
|
}.should_not raise_error
|
343
380
|
lambda {
|
344
|
-
|
381
|
+
metadata.attribute("db/mysql/databases", :calculated => false)
|
345
382
|
}.should_not raise_error
|
346
383
|
lambda {
|
347
|
-
|
384
|
+
metadata.attribute("db/mysql/databases", :calculated => Hash.new)
|
348
385
|
}.should raise_error(ArgumentError)
|
349
386
|
end
|
350
387
|
|
351
388
|
it "should set calculated to false by default" do
|
352
|
-
|
353
|
-
|
389
|
+
metadata.attribute("db/mysql/databases", {})
|
390
|
+
metadata.attributes["db/mysql/databases"][:calculated].should == false
|
354
391
|
end
|
355
392
|
|
356
393
|
it "accepts String for the attribute type" do
|
357
394
|
lambda {
|
358
|
-
|
395
|
+
metadata.attribute("db/mysql/databases", :type => "string")
|
359
396
|
}.should_not raise_error
|
360
397
|
end
|
361
398
|
|
362
399
|
it "accepts Array for the attribute type" do
|
363
400
|
lambda {
|
364
|
-
|
401
|
+
metadata.attribute("db/mysql/databases", :type => "array")
|
365
402
|
}.should_not raise_error
|
366
403
|
lambda {
|
367
|
-
|
404
|
+
metadata.attribute("db/mysql/databases", :type => Array.new)
|
368
405
|
}.should raise_error(ArgumentError)
|
369
406
|
end
|
370
407
|
|
371
408
|
it "accepts symbol for the attribute type" do
|
372
409
|
lambda {
|
373
|
-
|
410
|
+
metadata.attribute("db/mysql/databases", :type => "symbol")
|
374
411
|
}.should_not raise_error
|
375
412
|
end
|
376
413
|
|
377
414
|
it "should let type be hash (backwards compatability only)" do
|
378
415
|
lambda {
|
379
|
-
|
416
|
+
metadata.attribute("db/mysql/databases", :type => "hash")
|
380
417
|
}.should_not raise_error
|
381
418
|
end
|
382
419
|
|
383
420
|
it "should let required be required, recommended or optional" do
|
384
421
|
lambda {
|
385
|
-
|
422
|
+
metadata.attribute("db/mysql/databases", :required => 'required')
|
386
423
|
}.should_not raise_error
|
387
424
|
lambda {
|
388
|
-
|
425
|
+
metadata.attribute("db/mysql/databases", :required => 'recommended')
|
389
426
|
}.should_not raise_error
|
390
427
|
lambda {
|
391
|
-
|
428
|
+
metadata.attribute("db/mysql/databases", :required => 'optional')
|
392
429
|
}.should_not raise_error
|
393
430
|
end
|
394
431
|
|
395
432
|
it "should convert required true to required" do
|
396
433
|
lambda {
|
397
|
-
|
434
|
+
metadata.attribute("db/mysql/databases", :required => true)
|
398
435
|
}.should_not raise_error
|
399
|
-
#attrib =
|
436
|
+
#attrib = metadata.attributes["db/mysql/databases"][:required].should == "required"
|
400
437
|
end
|
401
438
|
|
402
439
|
it "should convert required false to optional" do
|
403
440
|
lambda {
|
404
|
-
|
441
|
+
metadata.attribute("db/mysql/databases", :required => false)
|
405
442
|
}.should_not raise_error
|
406
|
-
#attrib =
|
443
|
+
#attrib = metadata.attributes["db/mysql/databases"][:required].should == "optional"
|
407
444
|
end
|
408
445
|
|
409
446
|
it "should set required to 'optional' by default" do
|
410
|
-
|
411
|
-
|
447
|
+
metadata.attribute("db/mysql/databases", {})
|
448
|
+
metadata.attributes["db/mysql/databases"][:required].should == 'optional'
|
412
449
|
end
|
413
450
|
|
414
451
|
it "should make sure recipes is an array" do
|
415
452
|
lambda {
|
416
|
-
|
453
|
+
metadata.attribute("db/mysql/databases", :recipes => [])
|
417
454
|
}.should_not raise_error
|
418
455
|
lambda {
|
419
|
-
|
456
|
+
metadata.attribute("db/mysql/databases", :required => Hash.new)
|
420
457
|
}.should raise_error(ArgumentError)
|
421
458
|
end
|
422
459
|
|
423
460
|
it "should set recipes to an empty array by default" do
|
424
|
-
|
425
|
-
|
461
|
+
metadata.attribute("db/mysql/databases", {})
|
462
|
+
metadata.attributes["db/mysql/databases"][:recipes].should == []
|
426
463
|
end
|
427
464
|
|
428
465
|
it "should allow the default value to be a string, array, hash, boolean or numeric" do
|
429
466
|
lambda {
|
430
|
-
|
467
|
+
metadata.attribute("db/mysql/databases", :default => [])
|
431
468
|
}.should_not raise_error
|
432
469
|
lambda {
|
433
|
-
|
470
|
+
metadata.attribute("db/mysql/databases", :default => {})
|
434
471
|
}.should_not raise_error
|
435
472
|
lambda {
|
436
|
-
|
473
|
+
metadata.attribute("db/mysql/databases", :default => "alice in chains")
|
437
474
|
}.should_not raise_error
|
438
475
|
lambda {
|
439
|
-
|
476
|
+
metadata.attribute("db/mysql/databases", :default => 1337)
|
440
477
|
}.should_not raise_error
|
441
478
|
lambda {
|
442
|
-
|
479
|
+
metadata.attribute("db/mysql/databases", :default => true)
|
443
480
|
}.should_not raise_error
|
444
481
|
lambda {
|
445
|
-
|
482
|
+
metadata.attribute("db/mysql/databases", :required => :not_gonna_do_it)
|
446
483
|
}.should raise_error(ArgumentError)
|
447
484
|
end
|
448
485
|
|
@@ -453,16 +490,16 @@ describe Chef::Cookbook::Metadata do
|
|
453
490
|
:default => "test1"
|
454
491
|
}
|
455
492
|
lambda {
|
456
|
-
|
493
|
+
metadata.attribute("test_cookbook/test", options)
|
457
494
|
}.should_not raise_error
|
458
|
-
|
495
|
+
|
459
496
|
options = {
|
460
497
|
:type => "boolean",
|
461
498
|
:choice => [ true, false ],
|
462
499
|
:default => true
|
463
500
|
}
|
464
501
|
lambda {
|
465
|
-
|
502
|
+
metadata.attribute("test_cookbook/test", options)
|
466
503
|
}.should_not raise_error
|
467
504
|
|
468
505
|
options = {
|
@@ -471,7 +508,7 @@ describe Chef::Cookbook::Metadata do
|
|
471
508
|
:default => 1337
|
472
509
|
}
|
473
510
|
lambda {
|
474
|
-
|
511
|
+
metadata.attribute("test_cookbook/test", options)
|
475
512
|
}.should_not raise_error
|
476
513
|
|
477
514
|
options = {
|
@@ -480,7 +517,7 @@ describe Chef::Cookbook::Metadata do
|
|
480
517
|
:default => false
|
481
518
|
}
|
482
519
|
lambda {
|
483
|
-
|
520
|
+
metadata.attribute("test_cookbook/test", options)
|
484
521
|
}.should raise_error
|
485
522
|
end
|
486
523
|
|
@@ -490,14 +527,14 @@ describe Chef::Cookbook::Metadata do
|
|
490
527
|
:calculated => true,
|
491
528
|
:default => [ "I thought you said calculated" ]
|
492
529
|
}
|
493
|
-
|
530
|
+
metadata.attribute("db/mysql/databases", attrs)
|
494
531
|
}.should raise_error(ArgumentError)
|
495
532
|
lambda {
|
496
533
|
attrs = {
|
497
534
|
:calculated => true,
|
498
535
|
:default => "I thought you said calculated"
|
499
536
|
}
|
500
|
-
|
537
|
+
metadata.attribute("db/mysql/databases", attrs)
|
501
538
|
}.should raise_error(ArgumentError)
|
502
539
|
end
|
503
540
|
|
@@ -507,14 +544,14 @@ describe Chef::Cookbook::Metadata do
|
|
507
544
|
:choice => [ "a", "b", "c"],
|
508
545
|
:default => "b"
|
509
546
|
}
|
510
|
-
|
547
|
+
metadata.attribute("db/mysql/databases", attrs)
|
511
548
|
}.should_not raise_error
|
512
549
|
lambda {
|
513
550
|
attrs = {
|
514
551
|
:choice => [ "a", "b", "c", "d", "e"],
|
515
552
|
:default => ["b", "d"]
|
516
553
|
}
|
517
|
-
|
554
|
+
metadata.attribute("db/mysql/databases", attrs)
|
518
555
|
}.should_not raise_error
|
519
556
|
end
|
520
557
|
|
@@ -524,71 +561,74 @@ describe Chef::Cookbook::Metadata do
|
|
524
561
|
:choice => [ "a", "b", "c"],
|
525
562
|
:default => "d"
|
526
563
|
}
|
527
|
-
|
564
|
+
metadata.attribute("db/mysql/databases", attrs)
|
528
565
|
}.should raise_error(ArgumentError)
|
529
566
|
lambda {
|
530
567
|
attrs = {
|
531
568
|
:choice => [ "a", "b", "c", "d", "e"],
|
532
569
|
:default => ["b", "z"]
|
533
570
|
}
|
534
|
-
|
571
|
+
metadata.attribute("db/mysql/databases", attrs)
|
535
572
|
}.should raise_error(ArgumentError)
|
536
573
|
end
|
537
574
|
end
|
538
575
|
|
539
576
|
describe "recipes" do
|
577
|
+
let(:cookbook) do
|
578
|
+
c = Chef::CookbookVersion.new('test_cookbook')
|
579
|
+
c.recipe_files = [ "default.rb", "enlighten.rb" ]
|
580
|
+
c
|
581
|
+
end
|
582
|
+
|
540
583
|
before(:each) do
|
541
|
-
|
542
|
-
|
584
|
+
metadata.name("test_cookbook")
|
585
|
+
metadata.recipes_from_cookbook_version(cookbook)
|
543
586
|
end
|
544
587
|
|
545
588
|
it "should have the names of the recipes" do
|
546
|
-
|
547
|
-
|
589
|
+
metadata.recipes["test_cookbook"].should == ""
|
590
|
+
metadata.recipes["test_cookbook::enlighten"].should == ""
|
548
591
|
end
|
549
592
|
|
550
593
|
it "should let you set the description for a recipe" do
|
551
|
-
|
552
|
-
|
594
|
+
metadata.recipe "test_cookbook", "It, um... tests stuff?"
|
595
|
+
metadata.recipes["test_cookbook"].should == "It, um... tests stuff?"
|
553
596
|
end
|
554
597
|
|
555
598
|
it "should automatically provide each recipe" do
|
556
|
-
|
557
|
-
|
599
|
+
metadata.providing.has_key?("test_cookbook").should == true
|
600
|
+
metadata.providing.has_key?("test_cookbook::enlighten").should == true
|
558
601
|
end
|
559
602
|
|
560
603
|
end
|
561
604
|
|
562
605
|
describe "json" do
|
563
606
|
before(:each) do
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
@meta.recipe "test_cookbook::enlighten", "is your buddy"
|
580
|
-
@meta.attribute "bizspark/has_login",
|
607
|
+
metadata.version "1.0"
|
608
|
+
metadata.maintainer "Bobo T. Clown"
|
609
|
+
metadata.maintainer_email "bobo@example.com"
|
610
|
+
metadata.long_description "I have a long arm!"
|
611
|
+
metadata.supports :ubuntu, "> 8.04"
|
612
|
+
metadata.depends "bobo", "= 1.0"
|
613
|
+
metadata.depends "bubu", "=1.0"
|
614
|
+
metadata.depends "bobotclown", "= 1.1"
|
615
|
+
metadata.recommends "snark", "< 3.0"
|
616
|
+
metadata.suggests "kindness", "> 2.0"
|
617
|
+
metadata.conflicts "hatred"
|
618
|
+
metadata.provides "foo(:bar, :baz)"
|
619
|
+
metadata.replaces "snarkitron"
|
620
|
+
metadata.recipe "test_cookbook::enlighten", "is your buddy"
|
621
|
+
metadata.attribute "bizspark/has_login",
|
581
622
|
:display_name => "You have nothing"
|
582
|
-
|
623
|
+
metadata.version "1.2.3"
|
583
624
|
end
|
584
625
|
|
585
626
|
describe "serialize" do
|
586
|
-
|
587
|
-
|
588
|
-
end
|
627
|
+
|
628
|
+
let(:deserialized_metadata) { Chef::JSONCompat.from_json(metadata.to_json) }
|
589
629
|
|
590
630
|
it "should serialize to a json hash" do
|
591
|
-
|
631
|
+
deserialized_metadata.should be_a_kind_of(Hash)
|
592
632
|
end
|
593
633
|
|
594
634
|
%w{
|
@@ -610,18 +650,18 @@ describe Chef::Cookbook::Metadata do
|
|
610
650
|
version
|
611
651
|
}.each do |t|
|
612
652
|
it "should include '#{t}'" do
|
613
|
-
|
653
|
+
deserialized_metadata[t].should == metadata.send(t.to_sym)
|
614
654
|
end
|
615
655
|
end
|
616
656
|
end
|
617
657
|
|
618
658
|
describe "deserialize" do
|
619
|
-
|
620
|
-
|
621
|
-
|
659
|
+
|
660
|
+
let(:deserialized_metadata) { Chef::Cookbook::Metadata.from_json(metadata.to_json) }
|
661
|
+
|
622
662
|
|
623
663
|
it "should deserialize to a Chef::Cookbook::Metadata object" do
|
624
|
-
|
664
|
+
deserialized_metadata.should be_a_kind_of(Chef::Cookbook::Metadata)
|
625
665
|
end
|
626
666
|
|
627
667
|
%w{
|
@@ -643,14 +683,14 @@ describe Chef::Cookbook::Metadata do
|
|
643
683
|
version
|
644
684
|
}.each do |t|
|
645
685
|
it "should match '#{t}'" do
|
646
|
-
|
686
|
+
deserialized_metadata.send(t.to_sym).should == metadata.send(t.to_sym)
|
647
687
|
end
|
648
688
|
end
|
649
689
|
end
|
650
690
|
|
651
691
|
describe "from_hash" do
|
652
692
|
before(:each) do
|
653
|
-
@hash =
|
693
|
+
@hash = metadata.to_hash
|
654
694
|
end
|
655
695
|
|
656
696
|
[:dependencies,
|