spec/integration/download_spec.rb in knife-essentials-0.8.4 vs spec/integration/download_spec.rb in knife-essentials-0.8.5
- old
+ new
@@ -132,10 +132,34 @@
knife('download /').should_succeed "Updated /roles/x.json\n"
knife('diff --name-status /').should_succeed ''
end
end
+ context 'except the role file is textually different, but not ACTUALLY different' do
+ file 'roles/x.json', <<EOM
+{
+ "chef_type": "role",
+ "default_attributes": {
+ },
+ "env_run_lists": {
+ },
+ "json_class": "Chef::Role",
+ "name": "x",
+ "description": "",
+ "override_attributes": {
+ },
+ "run_list": [
+
+ ]
+}
+EOM
+ it 'knife download / does not change anything' do
+ knife('download /').should_succeed ''
+ knife('diff --name-status /').should_succeed ''
+ end
+ end
+
context 'as well as one extra copy of each thing' do
file 'clients/y.json', { 'name' => 'y' }
file 'cookbooks/x/blah.rb', ''
file 'cookbooks/y/metadata.rb', 'version "1.0.0"'
file 'data_bags/x/z.json', <<EOM
@@ -335,10 +359,32 @@
Updated /data_bags/x/modified.json
Deleted extra entry /data_bags/x/deleted.json (purge is on)
EOM
knife('diff --name-status /data_bags').should_succeed ''
end
+ context 'when cwd is the /data_bags directory' do
+ cwd 'data_bags'
+ it 'knife download fails' do
+ knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/
+ end
+ it 'knife download --purge . downloads everything' do
+ knife('download --purge .').should_succeed <<EOM
+Created x/added.json
+Updated x/modified.json
+Deleted extra entry x/deleted.json (purge is on)
+EOM
+ knife('diff --name-status /data_bags').should_succeed ''
+ end
+ it 'knife download --purge * downloads everything' do
+ knife('download --purge *').should_succeed <<EOM
+Created x/added.json
+Updated x/modified.json
+Deleted extra entry x/deleted.json (purge is on)
+EOM
+ knife('diff --name-status /data_bags').should_succeed ''
+ end
+ end
end
end
when_the_repository 'has a cookbook' do
file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
@@ -394,10 +440,61 @@
knife('diff --name-status /cookbooks').should_succeed ''
end
end
end
- # download from a cwd
- # download with *'s
- # download with JSON that isn't *really* modified
- # Multiple cookbook versions!!!
+ when_the_repository 'has a cookbook' do
+ file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
+ file 'cookbooks/x/onlyin1.0.0.rb', 'old_text'
+
+ when_the_chef_server 'has a later version for the cookbook' do
+ cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"', 'onlyin1.0.0.rb' => '' }
+ cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => 'hi' }
+
+ it 'knife download /cookbooks/x downloads the latest version' do
+ knife('download --purge /cookbooks/x').should_succeed <<EOM
+Updated /cookbooks/x/metadata.rb
+Created /cookbooks/x/onlyin1.0.1.rb
+Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
+EOM
+ knife('diff --name-status /cookbooks').should_succeed ''
+ end
+ end
+
+ when_the_chef_server 'has an earlier version for the cookbook' do
+ cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"', 'onlyin1.0.0.rb' => ''}
+ cookbook 'x', '0.9.9', { 'metadata.rb' => 'version "0.9.9"', 'onlyin0.9.9.rb' => 'hi' }
+ it 'knife download /cookbooks/x downloads the updated file' do
+ knife('download --purge /cookbooks/x').should_succeed <<EOM
+Updated /cookbooks/x/onlyin1.0.0.rb
+EOM
+ knife('diff --name-status /cookbooks').should_succeed ''
+ end
+ end
+
+ when_the_chef_server 'has a later version for the cookbook, and no current version' do
+ cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => 'hi' }
+
+ it 'knife download /cookbooks/x downloads the latest version' do
+ knife('download --purge /cookbooks/x').should_succeed <<EOM
+Updated /cookbooks/x/metadata.rb
+Created /cookbooks/x/onlyin1.0.1.rb
+Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
+EOM
+ knife('diff --name-status /cookbooks').should_succeed ''
+ end
+ end
+
+ when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
+ cookbook 'x', '0.9.9', { 'metadata.rb' => 'version "0.9.9"', 'onlyin0.9.9.rb' => 'hi' }
+
+ it 'knife download /cookbooks/x downloads the old version' do
+ knife('download --purge /cookbooks/x').should_succeed <<EOM
+Updated /cookbooks/x/metadata.rb
+Created /cookbooks/x/onlyin0.9.9.rb
+Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
+EOM
+ knife('diff --name-status /cookbooks').should_succeed ''
+ end
+ end
+ end
end