diff options
author | Ho-Sheng Hsiao <hosh@opscode.com> | 2013-02-15 14:44:35 -0800 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-06-07 13:12:26 -0700 |
commit | 57f7c1215bf19f6edbe1b9956ec8857d7a45823a (patch) | |
tree | 9299c74b6a57c7f112eb5416e7e140fa3a95e384 /spec/support/shared/integration/integration_helper.rb | |
parent | 0c8bf48ddb68dcfb2e5cc1758927da9e8a9caab3 (diff) | |
download | chef-57f7c1215bf19f6edbe1b9956ec8857d7a45823a.tar.gz |
[SPEC] Added upload and download specs with cookbook versions
- Specs assume that Chef requires name attribute in the metadata
Diffstat (limited to 'spec/support/shared/integration/integration_helper.rb')
-rw-r--r-- | spec/support/shared/integration/integration_helper.rb | 80 |
1 files changed, 69 insertions, 11 deletions
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index 80a0ff6d7c..8e1ceb077e 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -31,7 +31,7 @@ module IntegrationSupport # Common layouts def one_of_each_resource_in_chef_server client 'x', '{}' - cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' } + cookbook 'x', '1.0.0', { 'metadata.rb' => ['name "x"', 'version "1.0.0"'].join("\n") } data_bag 'x', { 'y' => '{}' } environment 'x', '{}' node 'x', '{}' @@ -43,10 +43,10 @@ module IntegrationSupport file 'clients/x.json', <<EOM {} EOM - if options[:versioned_cookbooks] - file 'cookbooks/x-1.0.0/metadata.rb', 'version "1.0.0"' + if metadata[:versioned_cookbooks] + file 'cookbooks/x-1.0.0/metadata.rb', ['name "x"', 'version "1.0.0"'].join("\n") else - file 'cookbooks/x/metadata.rb', 'version "1.0.0"' + file 'cookbooks/x/metadata.rb', [ 'name "x"', 'version "1.0.0"'].join("\n") end file 'data_bags/x/y.json', <<EOM @@ -107,6 +107,62 @@ EOM EOM end + def extra_resources_in_repository + # Extra files not found in the standard resource set + file 'clients/y.json', { 'name' => 'y' } + if metadata[:versioned_cookbooks] + file 'cookbooks/x-1.0.0/blah.rb', '' + file 'cookbooks/x-2.0.0/metadata.rb', ['name "x"', 'version "2.0.0"'].join("\n") + file 'cookbooks/y-1.0.0/metadata.rb', ['name "y"', 'version "1.0.0"'].join("\n") + else + file 'cookbooks/x/blah.rb', '' + file 'cookbooks/y/metadata.rb', ['name "y"', 'version "1.0.0"'].join("\n") + end + file 'data_bags/x/z.json', <<EOM +{ + "id": "z" +} +EOM + file 'data_bags/y/zz.json', <<EOM +{ + "id": "zz" +} +EOM + file 'environments/y.json', <<EOM +{ + "chef_type": "environment", + "cookbook_versions": { + }, + "default_attributes": { + }, + "description": "", + "json_class": "Chef::Environment", + "name": "y", + "override_attributes": { + } +} +EOM + file 'nodes/y.json', { 'name' => 'y' } + file 'roles/y.json', <<EOM +{ + "chef_type": "role", + "default_attributes": { + }, + "description": "", + "env_run_lists": { + }, + "json_class": "Chef::Role", + "name": "y", + "override_attributes": { + }, + "run_list": [ + + ] +} +EOM + file 'users/y.json', { 'name' => 'y' } + end + # Integration DSL @@ -211,18 +267,20 @@ EOM # Versioned cookbooks - def with_versioned_cookbooks(&block) - context 'with versioned cookbooks' do - before(:each) { Chef::Config.versioned_cookbooks = true } - after(:each) { Chef::Config.versioned_cookbooks = false } + def with_versioned_cookbooks(_metadata = {}, &block) + _m = { :versioned_cookbooks => true }.merge(_metadata) + context 'with versioned cookbooks', _m do + before(:each) { Chef::Config[:versioned_cookbooks] = true } + after(:each) { Chef::Config[:versioned_cookbooks] = false } instance_eval(&block) end end - def without_versioned_cookbooks(&block) - context 'with versioned cookbooks' do + def without_versioned_cookbooks(_metadata = {}, &block) + _m = { :versioned_cookbooks => false }.merge(_metadata) + context 'with versioned cookbooks', _m do # Just make sure this goes back to default - before(:each) { Chef::Config.versioned_cookbooks = false } + before(:each) { Chef::Config[:versioned_cookbooks] = false } instance_eval(&block) end end |