diff options
author | Ho-Sheng Hsiao <hosh@opscode.com> | 2013-02-13 17:08:09 -0800 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-06-07 13:12:26 -0700 |
commit | 6e83b2164fc692f013c78c0eff9abf9903315e6d (patch) | |
tree | ab1b8003d30ba9ed586d51fd7ce6e7b4a6f47c66 | |
parent | 49495b1974cd6c7eb0d258e605b5111b2b2a730b (diff) | |
download | chef-6e83b2164fc692f013c78c0eff9abf9903315e6d.tar.gz |
[SPEC] Added versioned cookbook helpers, added some upload specs
-rw-r--r-- | spec/integration/knife/upload_spec.rb | 79 | ||||
-rw-r--r-- | spec/support/shared/integration/integration_helper.rb | 21 |
2 files changed, 75 insertions, 25 deletions
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb index 78a699b4a3..6ce331bfad 100644 --- a/spec/integration/knife/upload_spec.rb +++ b/spec/integration/knife/upload_spec.rb @@ -24,29 +24,56 @@ describe 'knife upload' do directory 'roles' directory 'users' - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + without_versioned_cookbooks do + it 'knife upload does nothing' do + knife('upload /').should_succeed '' + knife('diff --name-status /').should_succeed <<EOM D\t/cookbooks/x D\t/data_bags/x D\t/environments/_default.json D\t/environments/x.json D\t/roles/x.json EOM - end + end - it 'knife upload --purge deletes everything' do - knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") + it 'knife upload --purge deletes everything' do + knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") Deleted extra entry /cookbooks/x (purge is on) Deleted extra entry /data_bags/x (purge is on) Deleted extra entry /environments/x.json (purge is on) Deleted extra entry /roles/x.json (purge is on) EOM - knife('diff --name-status /').should_succeed <<EOM + knife('diff --name-status /').should_succeed <<EOM D\t/environments/_default.json EOM + end end - end + + with_versioned_cookbooks do + it 'knife upload does nothing' do + knife('upload /').should_succeed '' + knife('diff --name-status /').should_succeed <<EOM +D\t/cookbooks/x-1.0.0 +D\t/data_bags/x +D\t/environments/_default.json +D\t/environments/x.json +D\t/roles/x.json +EOM + end + + it 'knife upload --purge deletes everything' do + knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") +Deleted extra entry /cookbooks/x-1.0.0 (purge is on) +Deleted extra entry /data_bags/x (purge is on) +Deleted extra entry /environments/x.json (purge is on) +Deleted extra entry /roles/x.json (purge is on) +EOM + knife('diff --name-status /').should_succeed <<EOM +D\t/environments/_default.json +EOM + end + end + end # when the repository has only top-level directories when_the_repository 'has an identical copy of each thing' do file 'clients/x.json', <<EOM @@ -228,42 +255,44 @@ Created /roles/y.json EOM knife('diff --name-status /').should_succeed '' end - end - end + end # when repository has an extra copy of each thing + end # when the repository has an identical copy of each thing when_the_repository 'is empty' do - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + with_all_types_of_repository_layouts do + it 'knife upload does nothing' do + knife('upload /').should_succeed '' + knife('diff --name-status /').should_succeed <<EOM D\t/cookbooks D\t/data_bags D\t/environments D\t/roles EOM - end + end - it 'knife upload --purge deletes nothing' do - knife('upload --purge /').should_fail <<EOM + it 'knife upload --purge deletes nothing' do + knife('upload --purge /').should_fail <<EOM ERROR: /cookbooks cannot be deleted. ERROR: /data_bags cannot be deleted. ERROR: /environments cannot be deleted. ERROR: /roles cannot be deleted. EOM - knife('diff --name-status /').should_succeed <<EOM + knife('diff --name-status /').should_succeed <<EOM D\t/cookbooks D\t/data_bags D\t/environments D\t/roles EOM - end - - context 'when current directory is top level' do - cwd '.' - it 'knife upload with no parameters reports an error' do - knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ end - end - end + + context 'when current directory is top level' do + cwd '.' + it 'knife upload with no parameters reports an error' do + knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ + end + end # when current directory is top level + end # with all types of repository layouts + end # when the directory is empty end # Test upload of an item when the other end doesn't even have the container diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index 843bf7d0c5..616577ffa7 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -27,6 +27,27 @@ require 'spec_helper' module IntegrationSupport include ChefZero::RSpec + def with_versioned_cookbooks(&block) + context 'with versioned cookbooks' 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 + # Just make sure this goes back to default + before(:each) { Chef::Config.versioned_cookbooks = false } + instance_eval(&block) + end + end + + def with_all_types_of_repository_layouts(&block) + without_versioned_cookbooks(&block) + with_versioned_cookbooks(&block) + end + def when_the_repository(description, *args, &block) context "When the local repository #{description}", *args do before :each do |