microwave 0.1006.33 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +79 -1
- data/Rakefile +120 -0
- data/bin/chef-client +26 -0
- data/bin/knife +26 -0
- data/{lib/chef/resources.rb → bin/shef} +21 -13
- data/distro/README +2 -0
- data/distro/arch/etc/conf.d/chef-client.conf +5 -0
- data/distro/arch/etc/conf.d/chef-expander.conf +8 -0
- data/distro/arch/etc/conf.d/chef-server-webui.conf +10 -0
- data/distro/arch/etc/conf.d/chef-server.conf +10 -0
- data/distro/arch/etc/conf.d/chef-solr.conf +8 -0
- data/distro/arch/etc/rc.d/chef-client +90 -0
- data/distro/arch/etc/rc.d/chef-expander +78 -0
- data/distro/arch/etc/rc.d/chef-server +78 -0
- data/distro/arch/etc/rc.d/chef-server-webui +78 -0
- data/distro/arch/etc/rc.d/chef-solr +78 -0
- data/distro/common/html/chef-client.8.html +145 -0
- data/distro/common/html/chef-expander.8.html +164 -0
- data/distro/common/html/chef-expanderctl.8.html +146 -0
- data/distro/common/html/chef-server-webui.8.html +185 -0
- data/distro/common/html/chef-server.8.html +182 -0
- data/distro/common/html/chef-solo.8.html +191 -0
- data/distro/common/html/chef-solr.8.html +165 -0
- data/distro/common/html/knife-bootstrap.1.html +241 -0
- data/distro/common/html/knife-client.1.html +219 -0
- data/distro/common/html/knife-configure.1.html +170 -0
- data/distro/common/html/knife-cookbook-site.1.html +241 -0
- data/distro/common/html/knife-cookbook.1.html +384 -0
- data/distro/common/html/knife-data-bag.1.html +238 -0
- data/distro/common/html/knife-environment.1.html +267 -0
- data/distro/common/html/knife-exec.1.html +134 -0
- data/distro/common/html/knife-index.1.html +125 -0
- data/distro/common/html/knife-node.1.html +250 -0
- data/distro/common/html/knife-recipe.1.html +92 -0
- data/distro/common/html/knife-role.1.html +200 -0
- data/distro/common/html/knife-search.1.html +288 -0
- data/distro/common/html/knife-ssh.1.html +156 -0
- data/distro/common/html/knife-status.1.html +128 -0
- data/distro/common/html/knife-tag.1.html +137 -0
- data/distro/common/html/knife.1.html +320 -0
- data/distro/common/html/shef.1.html +283 -0
- data/distro/common/man/man1/knife-bootstrap.1 +201 -0
- data/distro/common/man/man1/knife-client.1 +99 -0
- data/distro/common/man/man1/knife-configure.1 +88 -0
- data/distro/common/man/man1/knife-cookbook-site.1 +145 -0
- data/distro/common/man/man1/knife-cookbook.1 +345 -0
- data/distro/common/man/man1/knife-data-bag.1 +136 -0
- data/distro/common/man/man1/knife-environment.1 +178 -0
- data/distro/common/man/man1/knife-exec.1 +46 -0
- data/distro/common/man/man1/knife-index.1 +29 -0
- data/distro/common/man/man1/knife-node.1 +134 -0
- data/distro/common/man/man1/knife-role.1 +88 -0
- data/distro/common/man/man1/knife-search.1 +280 -0
- data/distro/common/man/man1/knife-ssh.1 +79 -0
- data/distro/common/man/man1/knife-status.1 +29 -0
- data/distro/common/man/man1/knife-tag.1 +43 -0
- data/distro/common/man/man1/knife.1 +288 -0
- data/distro/common/man/man1/shef.1 +256 -0
- data/distro/common/man/man8/chef-client.8 +104 -0
- data/distro/common/man/man8/chef-expander.8 +97 -0
- data/distro/common/man/man8/chef-expanderctl.8 +62 -0
- data/distro/common/man/man8/chef-server-webui.8 +155 -0
- data/distro/common/man/man8/chef-server.8 +147 -0
- data/distro/common/man/man8/chef-solo.8 +158 -0
- data/distro/common/man/man8/chef-solr.8 +122 -0
- data/distro/common/markdown/README +3 -0
- data/distro/common/markdown/man1/knife-bootstrap.mkd +141 -0
- data/distro/common/markdown/man1/knife-client.mkd +103 -0
- data/distro/common/markdown/man1/knife-configure.mkd +70 -0
- data/distro/common/markdown/man1/knife-cookbook-site.mkd +123 -0
- data/distro/common/markdown/man1/knife-cookbook.mkd +263 -0
- data/distro/common/markdown/man1/knife-data-bag.mkd +121 -0
- data/distro/common/markdown/man1/knife-environment.mkd +151 -0
- data/distro/common/markdown/man1/knife-exec.mkd +37 -0
- data/distro/common/markdown/man1/knife-index.mkd +30 -0
- data/distro/common/markdown/man1/knife-node.mkd +130 -0
- data/distro/common/markdown/man1/knife-role.mkd +85 -0
- data/distro/common/markdown/man1/knife-search.mkd +180 -0
- data/distro/common/markdown/man1/knife-ssh.mkd +69 -0
- data/distro/common/markdown/man1/knife-status.mkd +36 -0
- data/distro/common/markdown/man1/knife-tag.mkd +39 -0
- data/distro/common/markdown/man1/knife.mkd +218 -0
- data/distro/common/markdown/man1/shef.mkd +189 -0
- data/distro/common/markdown/man8/chef-client.mkd +74 -0
- data/distro/common/markdown/man8/chef-expander.mkd +82 -0
- data/distro/common/markdown/man8/chef-expanderctl.mkd +58 -0
- data/distro/common/markdown/man8/chef-server-webui.mkd +121 -0
- data/distro/common/markdown/man8/chef-server.mkd +121 -0
- data/distro/common/markdown/man8/chef-solo.mkd +107 -0
- data/distro/common/markdown/man8/chef-solr.mkd +89 -0
- data/distro/debian/etc/default/chef-client +4 -0
- data/distro/debian/etc/default/chef-expander +8 -0
- data/distro/debian/etc/default/chef-server +9 -0
- data/distro/debian/etc/default/chef-server-webui +9 -0
- data/distro/debian/etc/default/chef-solr +8 -0
- data/distro/debian/etc/init.d/chef-client +210 -0
- data/distro/debian/etc/init.d/chef-expander +176 -0
- data/distro/debian/etc/init.d/chef-server +122 -0
- data/distro/debian/etc/init.d/chef-server-webui +123 -0
- data/distro/debian/etc/init.d/chef-solr +176 -0
- data/distro/debian/etc/init/chef-client.conf +17 -0
- data/distro/debian/etc/init/chef-expander.conf +17 -0
- data/distro/debian/etc/init/chef-server-webui.conf +17 -0
- data/distro/debian/etc/init/chef-server.conf +17 -0
- data/distro/debian/etc/init/chef-solr.conf +17 -0
- data/distro/redhat/etc/init.d/chef-client +121 -0
- data/distro/redhat/etc/init.d/chef-expander +104 -0
- data/distro/redhat/etc/init.d/chef-server +112 -0
- data/distro/redhat/etc/init.d/chef-server-webui +112 -0
- data/distro/redhat/etc/init.d/chef-solr +104 -0
- data/distro/redhat/etc/logrotate.d/chef-client +8 -0
- data/distro/redhat/etc/logrotate.d/chef-expander +8 -0
- data/distro/redhat/etc/logrotate.d/chef-server +8 -0
- data/distro/redhat/etc/logrotate.d/chef-server-webui +8 -0
- data/distro/redhat/etc/logrotate.d/chef-solr +8 -0
- data/distro/redhat/etc/sysconfig/chef-client +15 -0
- data/distro/redhat/etc/sysconfig/chef-expander +7 -0
- data/distro/redhat/etc/sysconfig/chef-server +14 -0
- data/distro/redhat/etc/sysconfig/chef-server-webui +14 -0
- data/distro/redhat/etc/sysconfig/chef-solr +8 -0
- data/distro/windows/service_manager.rb +164 -0
- data/lib/chef.rb +7 -6
- data/spec/data/bad-config.rb +1 -0
- data/spec/data/big_json.json +1 -0
- data/spec/data/big_json_plus_one.json +1 -0
- data/spec/data/bootstrap/test-hints.erb +12 -0
- data/spec/data/bootstrap/test.erb +1 -0
- data/spec/data/cb_version_cookbooks/tatft/README.rdoc +3 -0
- data/spec/data/cb_version_cookbooks/tatft/attributes/default.rb +1 -0
- data/spec/data/cb_version_cookbooks/tatft/definitions/runit_service.rb +1 -0
- data/spec/data/cb_version_cookbooks/tatft/files/default/giant_blob.tgz +1 -0
- data/spec/data/cb_version_cookbooks/tatft/libraries/ownage.rb +1 -0
- data/spec/data/cb_version_cookbooks/tatft/providers/lwp.rb +1 -0
- data/spec/data/cb_version_cookbooks/tatft/recipes/default.rb +1 -0
- data/spec/data/cb_version_cookbooks/tatft/resources/lwr.rb +1 -0
- data/spec/data/cb_version_cookbooks/tatft/templates/default/configuration.erb +0 -0
- data/spec/data/checksum/random.txt +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-600hhz-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-6m8zdk-0 +0 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ahd2gq-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-api8ux-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-b0r1m1-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-bfygsi-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-el14l6-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ivrl3y-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-kkbs85-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ory1ux-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-pgsq76-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ra8uim-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-t7k1g-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-t8g0sv-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ufy6g3-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-x2d6j9-0 +1 -0
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-xi0l6h-0 +1 -0
- data/spec/data/config.rb +6 -0
- data/spec/data/cookbooks/angrybash/recipes/default.rb +8 -0
- data/spec/data/cookbooks/apache2/files/default/apache2_module_conf_generate.pl +2 -0
- data/spec/data/cookbooks/apache2/recipes/default.rb +3 -0
- data/spec/data/cookbooks/borken/recipes/default.rb +2 -0
- data/spec/data/cookbooks/borken/templates/default/borken.erb +2 -0
- data/spec/data/cookbooks/chefignore +6 -0
- data/spec/data/cookbooks/java/files/default/java.response +2 -0
- data/spec/data/cookbooks/openldap/attributes/default.rb +15 -0
- data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -0
- data/spec/data/cookbooks/openldap/definitions/client.rb +5 -0
- data/spec/data/cookbooks/openldap/definitions/server.rb +5 -0
- data/spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file1.txt +3 -0
- data/spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file2.txt +3 -0
- data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file1.txt +3 -0
- data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file2.txt +3 -0
- data/spec/data/cookbooks/openldap/files/default/remotedir/subdir_with_no_file_just_a_subsubdir/the_subsubdir/some_file.txt +3 -0
- data/spec/data/cookbooks/openldap/recipes/default.rb +3 -0
- data/spec/data/cookbooks/openldap/recipes/gigantor.rb +3 -0
- data/spec/data/cookbooks/openldap/recipes/one.rb +15 -0
- data/spec/data/cookbooks/openldap/templates/default/openldap_stuff.conf.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/openldap_variable_stuff.conf.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/test.erb +1 -0
- data/spec/data/definitions/test.rb +5 -0
- data/spec/data/environment-config.rb +5 -0
- data/spec/data/fileedit/blank +0 -0
- data/spec/data/fileedit/hosts +4 -0
- data/spec/data/gems/chef-integration-test-0.1.0.gem +0 -0
- data/spec/data/kitchen/chefignore +6 -0
- data/spec/data/kitchen/openldap/attributes/default.rb +3 -0
- data/spec/data/kitchen/openldap/attributes/robinson.rb +3 -0
- data/spec/data/kitchen/openldap/definitions/client.rb +3 -0
- data/spec/data/kitchen/openldap/definitions/drewbarrymore.rb +3 -0
- data/spec/data/kitchen/openldap/recipes/gigantor.rb +3 -0
- data/spec/data/kitchen/openldap/recipes/ignoreme.rb +3 -0
- data/spec/data/kitchen/openldap/recipes/woot.rb +3 -0
- data/spec/data/knife-site-subcommands/plugins/knife/example_subcommand.rb +0 -0
- data/spec/data/knife_subcommand/test_explicit_category.rb +7 -0
- data/spec/data/knife_subcommand/test_name_mapping.rb +4 -0
- data/spec/data/knife_subcommand/test_yourself.rb +13 -0
- data/spec/data/lwrp/providers/buck_passer.rb +3 -0
- data/spec/data/lwrp/providers/buck_passer_2.rb +10 -0
- data/spec/data/lwrp/providers/embedded_resource_accesses_providers_scope.rb +16 -0
- data/spec/data/lwrp/providers/monkey_name_printer.rb +5 -0
- data/spec/data/lwrp/providers/paint_drying_watcher.rb +7 -0
- data/spec/data/lwrp/providers/thumb_twiddler.rb +7 -0
- data/spec/data/lwrp/resources/bar.rb +1 -0
- data/spec/data/lwrp/resources/foo.rb +3 -0
- data/spec/data/lwrp/resources_with_default_attributes/nodeattr.rb +1 -0
- data/spec/data/lwrp_override/providers/buck_passer.rb +10 -0
- data/spec/data/lwrp_override/resources/foo.rb +4 -0
- data/spec/data/metadata/quick_start/metadata.rb +19 -0
- data/spec/data/nodes/default.rb +15 -0
- data/spec/data/nodes/test.example.com.rb +17 -0
- data/spec/data/nodes/test.rb +15 -0
- data/spec/data/object_loader/environments/test.json +5 -0
- data/spec/data/object_loader/environments/test.rb +2 -0
- data/spec/data/object_loader/environments/test_json_class.json +6 -0
- data/spec/data/object_loader/nodes/test.json +5 -0
- data/spec/data/object_loader/nodes/test.rb +2 -0
- data/spec/data/object_loader/nodes/test_json_class.json +6 -0
- data/spec/data/object_loader/roles/test.json +5 -0
- data/spec/data/object_loader/roles/test.rb +2 -0
- data/spec/data/object_loader/roles/test_json_class.json +6 -0
- data/spec/data/old_home_dir/my-dot-emacs +0 -0
- data/spec/data/old_home_dir/my-dot-vim +0 -0
- data/spec/data/recipes/test.rb +7 -0
- data/spec/data/remote_directory_data/remote_dir_file.txt +1 -0
- data/spec/data/remote_directory_data/remote_subdirectory/remote_subdir_file.txt +1 -0
- data/spec/data/remote_file/nyan_cat.png +0 -0
- data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -0
- data/spec/data/run_context/cookbooks/test/definitions/new_animals.rb +9 -0
- data/spec/data/run_context/cookbooks/test/definitions/new_cat.rb +5 -0
- data/spec/data/run_context/cookbooks/test/recipes/default.rb +5 -0
- data/spec/data/run_context/cookbooks/test/recipes/one.rb +7 -0
- data/spec/data/run_context/cookbooks/test/recipes/two.rb +7 -0
- data/spec/data/run_context/nodes/run_context.rb +5 -0
- data/spec/data/search_queries_to_transform.txt +98 -0
- data/spec/data/ssl/5e707473.0 +18 -0
- data/spec/data/ssl/chef-rspec.cert +27 -0
- data/spec/data/ssl/chef-rspec.key +27 -0
- data/spec/data/ssl/key.pem +15 -0
- data/spec/data/ssl/private_key.pem +27 -0
- data/spec/data/ssl/private_key_with_whitespace.pem +32 -0
- data/spec/data/templates/seattle.txt +1 -0
- data/spec/functional/knife/cookbook_delete_spec.rb +162 -0
- data/spec/functional/knife/exec_spec.rb +62 -0
- data/spec/functional/knife/ssh_spec.rb +211 -0
- data/spec/functional/resource/cookbook_file_spec.rb +51 -0
- data/spec/functional/resource/directory_spec.rb +39 -0
- data/spec/functional/resource/file_spec.rb +69 -0
- data/spec/functional/resource/link_spec.rb +572 -0
- data/spec/functional/resource/remote_directory_spec.rb +114 -0
- data/spec/functional/resource/remote_file_spec.rb +58 -0
- data/spec/functional/resource/template_spec.rb +68 -0
- data/spec/functional/tiny_server_spec.rb +77 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec_helper.rb +77 -0
- data/spec/stress/win32/file_spec.rb +37 -0
- data/{lib/chef/checksum/storage.rb → spec/stress/win32/memory_spec.rb} +8 -4
- data/spec/stress/win32/security_spec.rb +69 -0
- data/spec/support/chef_helpers.rb +52 -0
- data/{lib/chef/mixin/checksum.rb → spec/support/lib/chef/provider/easy.rb} +11 -8
- data/{lib/chef/mixin/check_helper.rb → spec/support/lib/chef/provider/snakeoil.rb} +18 -9
- data/{lib/chef/resource_definition_list.rb → spec/support/lib/chef/resource/cat.rb} +19 -16
- data/spec/support/lib/chef/resource/one_two_three_four.rb +43 -0
- data/{lib/chef/resource/cookbook_file.rb → spec/support/lib/chef/resource/zen_master.rb} +15 -14
- data/spec/support/matchers/leak.rb +96 -0
- data/spec/support/mock/constant.rb +52 -0
- data/spec/support/mock/platform.rb +18 -0
- data/spec/support/platform_helpers.rb +31 -0
- data/spec/support/platforms/prof/gc.rb +54 -0
- data/spec/support/platforms/prof/win32.rb +46 -0
- data/spec/support/shared/functional/directory_resource.rb +85 -0
- data/spec/support/shared/functional/file_resource.rb +173 -0
- data/spec/support/shared/functional/knife.rb +37 -0
- data/spec/support/shared/functional/securable_resource.rb +394 -0
- data/spec/support/shared/unit/api_error_inspector.rb +192 -0
- data/spec/tiny_server.rb +183 -0
- data/spec/unit/api_client_spec.rb +184 -0
- data/spec/unit/application/agent_spec.rb +0 -0
- data/spec/unit/application/client_spec.rb +136 -0
- data/spec/unit/application/knife_spec.rb +152 -0
- data/spec/unit/application/server_spec.rb +0 -0
- data/spec/unit/application/solo_spec.rb +167 -0
- data/spec/unit/application_spec.rb +239 -0
- data/spec/unit/certificate_spec.rb +76 -0
- data/spec/unit/checksum/storage/filesystem_spec.rb +69 -0
- data/spec/unit/checksum_cache_spec.rb +209 -0
- data/spec/unit/checksum_spec.rb +94 -0
- data/spec/unit/chef_spec.rb +25 -0
- data/spec/unit/client_spec.rb +290 -0
- data/spec/unit/config_spec.rb +215 -0
- data/spec/unit/cookbook/chefignore_spec.rb +38 -0
- data/spec/unit/cookbook/metadata_spec.rb +627 -0
- data/spec/unit/cookbook/synchronizer_spec.rb +258 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +211 -0
- data/spec/unit/cookbook_loader_spec.rb +145 -0
- data/spec/unit/cookbook_manifest_spec.rb +554 -0
- data/spec/unit/cookbook_spec.rb +101 -0
- data/spec/unit/cookbook_version_spec.rb +406 -0
- data/spec/unit/couchdb_spec.rb +274 -0
- data/spec/unit/daemon_spec.rb +281 -0
- data/spec/unit/data_bag_item_spec.rb +280 -0
- data/spec/unit/data_bag_spec.rb +169 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +122 -0
- data/spec/unit/environment_spec.rb +492 -0
- data/spec/unit/exceptions_spec.rb +74 -0
- data/spec/unit/file_access_control_spec.rb +282 -0
- data/spec/unit/file_cache_spec.rb +114 -0
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +202 -0
- data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +93 -0
- data/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb +43 -0
- data/{lib/chef/version.rb → spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb} +12 -8
- data/{lib/chef/providers.rb → spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb} +12 -10
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +162 -0
- data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +93 -0
- data/spec/unit/handler/json_file_spec.rb +64 -0
- data/spec/unit/handler_spec.rb +216 -0
- data/spec/unit/index_queue_spec.rb +391 -0
- data/spec/unit/json_compat_spect.rb +53 -0
- data/spec/unit/knife/bootstrap_spec.rb +214 -0
- data/spec/unit/knife/client_bulk_delete_spec.rb +78 -0
- data/spec/unit/knife/client_create_spec.rb +74 -0
- data/spec/unit/knife/client_delete_spec.rb +40 -0
- data/spec/unit/knife/client_edit_spec.rb +40 -0
- data/{lib/chef/handler/error_report.rb → spec/unit/knife/client_list_spec.rb} +15 -14
- data/spec/unit/knife/client_reregister_spec.rb +61 -0
- data/spec/unit/knife/client_show_spec.rb +42 -0
- data/spec/unit/knife/config_file_selection_spec.rb +118 -0
- data/spec/unit/knife/configure_client_spec.rb +83 -0
- data/spec/unit/knife/configure_spec.rb +229 -0
- data/spec/unit/knife/cookbook_bulk_delete_spec.rb +87 -0
- data/spec/unit/knife/cookbook_create_spec.rb +271 -0
- data/spec/unit/knife/cookbook_delete_spec.rb +239 -0
- data/spec/unit/knife/cookbook_download_spec.rb +217 -0
- data/spec/unit/knife/cookbook_list_spec.rb +88 -0
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +65 -0
- data/spec/unit/knife/cookbook_metadata_spec.rb +172 -0
- data/spec/unit/knife/cookbook_show_spec.rb +223 -0
- data/spec/unit/knife/cookbook_site_download_spec.rb +151 -0
- data/spec/unit/knife/cookbook_site_install_spec.rb +138 -0
- data/spec/unit/knife/cookbook_site_share_spec.rb +146 -0
- data/spec/unit/knife/cookbook_site_unshare_spec.rb +77 -0
- data/spec/unit/knife/cookbook_test_spec.rb +83 -0
- data/spec/unit/knife/cookbook_upload_spec.rb +144 -0
- data/spec/unit/knife/core/bootstrap_context_spec.rb +128 -0
- data/spec/unit/knife/core/cookbook_scm_repo_spec.rb +187 -0
- data/spec/unit/knife/core/object_loader_spec.rb +81 -0
- data/spec/unit/knife/core/subcommand_loader_spec.rb +54 -0
- data/spec/unit/knife/core/ui_spec.rb +160 -0
- data/spec/unit/knife/data_bag_create_spec.rb +96 -0
- data/spec/unit/knife/data_bag_edit_spec.rb +83 -0
- data/spec/unit/knife/data_bag_from_file_spec.rb +184 -0
- data/spec/unit/knife/data_bag_show_spec.rb +105 -0
- data/spec/unit/knife/environment_create_spec.rb +91 -0
- data/spec/unit/knife/environment_delete_spec.rb +71 -0
- data/spec/unit/knife/environment_edit_spec.rb +79 -0
- data/spec/unit/knife/environment_from_file_spec.rb +89 -0
- data/spec/unit/knife/environment_list_spec.rb +54 -0
- data/spec/unit/knife/environment_show_spec.rb +52 -0
- data/spec/unit/knife/index_rebuild_spec.rb +65 -0
- data/spec/unit/knife/knife_help.rb +92 -0
- data/spec/unit/knife/node_bulk_delete_spec.rb +97 -0
- data/spec/unit/knife/node_delete_spec.rb +68 -0
- data/spec/unit/knife/node_edit_spec.rb +88 -0
- data/spec/unit/knife/node_from_file_spec.rb +59 -0
- data/spec/unit/knife/node_list_spec.rb +63 -0
- data/spec/unit/knife/node_run_list_add_spec.rb +125 -0
- data/spec/unit/knife/node_run_list_remove_spec.rb +73 -0
- data/spec/unit/knife/node_show_spec.rb +48 -0
- data/spec/unit/knife/role_bulk_delete_spec.rb +80 -0
- data/spec/unit/knife/role_create_spec.rb +80 -0
- data/spec/unit/knife/role_delete_spec.rb +67 -0
- data/spec/unit/knife/role_edit_spec.rb +79 -0
- data/spec/unit/knife/role_from_file_spec.rb +69 -0
- data/spec/unit/knife/role_list_spec.rb +56 -0
- data/spec/unit/knife/ssh_spec.rb +184 -0
- data/spec/unit/knife/status_spec.rb +43 -0
- data/spec/unit/knife/tag_create_spec.rb +23 -0
- data/spec/unit/knife/tag_delete_spec.rb +25 -0
- data/spec/unit/knife/tag_list_spec.rb +23 -0
- data/spec/unit/knife_spec.rb +295 -0
- data/{lib/chef/log.rb → spec/unit/log_spec.rb} +6 -21
- data/spec/unit/lwrp_spec.rb +231 -0
- data/spec/unit/mash_spec.rb +51 -0
- data/spec/unit/mixin/checksum_spec.rb +41 -0
- data/spec/unit/mixin/command_spec.rb +105 -0
- data/spec/unit/mixin/convert_to_class_name_spec.rb +50 -0
- data/spec/unit/mixin/deep_merge_spec.rb +786 -0
- data/{lib/chef/mixin/shell_out.rb → spec/unit/mixin/deprecation_spec.rb} +15 -23
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +90 -0
- data/spec/unit/mixin/language_spec.rb +305 -0
- data/spec/unit/mixin/params_validate_spec.rb +370 -0
- data/spec/unit/mixin/path_sanity_spec.rb +80 -0
- data/spec/unit/mixin/securable_spec.rb +254 -0
- data/spec/unit/mixin/shell_out_spec.rb +109 -0
- data/spec/unit/mixin/template_spec.rb +104 -0
- data/spec/unit/mixin/xml_escape_spec.rb +54 -0
- data/spec/unit/monkey_patches/string_spec.rb +37 -0
- data/spec/unit/node/attribute_spec.rb +1033 -0
- data/spec/unit/node_spec.rb +744 -0
- data/spec/unit/openid_registration_spec.rb +153 -0
- data/spec/unit/platform_spec.rb +240 -0
- data/spec/unit/provider/breakpoint_spec.rb +54 -0
- data/spec/unit/provider/cookbook_file_spec.rb +218 -0
- data/spec/unit/provider/cron/solaris_spec.rb +121 -0
- data/spec/unit/provider/cron_spec.rb +812 -0
- data/spec/unit/provider/deploy/revision_spec.rb +109 -0
- data/spec/unit/provider/deploy/timestamped_spec.rb +40 -0
- data/spec/unit/provider/deploy_spec.rb +654 -0
- data/spec/unit/provider/directory_spec.rb +153 -0
- data/spec/unit/provider/env_spec.rb +232 -0
- data/spec/unit/provider/erl_call_spec.rb +88 -0
- data/spec/unit/provider/execute_spec.rb +63 -0
- data/spec/unit/provider/file_spec.rb +504 -0
- data/spec/unit/provider/git_spec.rb +352 -0
- data/spec/unit/provider/group/dscl_spec.rb +294 -0
- data/spec/unit/provider/group/gpasswd_spec.rb +108 -0
- data/spec/unit/provider/group/groupadd_spec.rb +161 -0
- data/spec/unit/provider/group/groupmod_spec.rb +134 -0
- data/spec/unit/provider/group/pw_spec.rb +140 -0
- data/spec/unit/provider/group/usermod_spec.rb +95 -0
- data/spec/unit/provider/group/windows_spec.rb +94 -0
- data/spec/unit/provider/group_spec.rb +259 -0
- data/spec/unit/provider/http_request_spec.rb +178 -0
- data/spec/unit/provider/ifconfig_spec.rb +213 -0
- data/spec/unit/provider/link_spec.rb +252 -0
- data/spec/unit/provider/log_spec.rb +81 -0
- data/spec/unit/provider/mdadm_spec.rb +128 -0
- data/spec/unit/provider/mount/mount_spec.rb +398 -0
- data/spec/unit/provider/mount/windows_spec.rb +134 -0
- data/spec/unit/provider/mount_spec.rb +160 -0
- data/spec/unit/provider/ohai_spec.rb +85 -0
- data/spec/unit/provider/package/apt_spec.rb +352 -0
- data/spec/unit/provider/package/dpkg_spec.rb +216 -0
- data/spec/unit/provider/package/easy_install_spec.rb +112 -0
- data/spec/unit/provider/package/freebsd_spec.rb +259 -0
- data/spec/unit/provider/package/ips_spec.rb +210 -0
- data/spec/unit/provider/package/macports_spec.rb +203 -0
- data/spec/unit/provider/package/pacman_spec.rb +206 -0
- data/spec/unit/provider/package/portage_spec.rb +276 -0
- data/spec/unit/provider/package/rpm_spec.rb +152 -0
- data/spec/unit/provider/package/rubygems_spec.rb +614 -0
- data/spec/unit/provider/package/smartos_spec.rb +83 -0
- data/spec/unit/provider/package/solaris_spec.rb +181 -0
- data/spec/unit/provider/package/yum_spec.rb +1795 -0
- data/spec/unit/provider/package/zypper_spec.rb +159 -0
- data/spec/unit/provider/package_spec.rb +427 -0
- data/spec/unit/provider/remote_directory_spec.rb +209 -0
- data/spec/unit/provider/remote_file_spec.rb +288 -0
- data/spec/unit/provider/route_spec.rb +230 -0
- data/spec/unit/provider/ruby_block_spec.rb +38 -0
- data/spec/unit/provider/script_spec.rb +96 -0
- data/spec/unit/provider/service/arch_service_spec.rb +330 -0
- data/spec/unit/provider/service/debian_service_spec.rb +254 -0
- data/spec/unit/provider/service/freebsd_service_spec.rb +379 -0
- data/spec/unit/provider/service/gentoo_service_spec.rb +144 -0
- data/spec/unit/provider/service/init_service_spec.rb +212 -0
- data/spec/unit/provider/service/insserv_service_spec.rb +76 -0
- data/spec/unit/provider/service/invokercd_service_spec.rb +212 -0
- data/spec/unit/provider/service/macosx_spec.rb +229 -0
- data/spec/unit/provider/service/redhat_spec.rb +156 -0
- data/spec/unit/provider/service/simple_service_spec.rb +171 -0
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +140 -0
- data/spec/unit/provider/service/systemd_service_spec.rb +239 -0
- data/spec/unit/provider/service/upstart_service_spec.rb +314 -0
- data/spec/unit/provider/service/windows_spec.rb +235 -0
- data/spec/unit/provider/service_spec.rb +169 -0
- data/spec/unit/provider/subversion_spec.rb +281 -0
- data/spec/unit/provider/template_spec.rb +196 -0
- data/spec/unit/provider/user/dscl_spec.rb +454 -0
- data/spec/unit/provider/user/pw_spec.rb +235 -0
- data/spec/unit/provider/user/useradd_spec.rb +386 -0
- data/spec/unit/provider/user/windows_spec.rb +178 -0
- data/spec/unit/provider/user_spec.rb +477 -0
- data/spec/unit/provider_spec.rb +168 -0
- data/spec/unit/recipe_spec.rb +268 -0
- data/spec/unit/resource/apt_package_spec.rb +43 -0
- data/spec/unit/resource/bash_spec.rb +40 -0
- data/spec/unit/resource/breakpoint_spec.rb +43 -0
- data/spec/unit/resource/chef_gem_spec.rb +49 -0
- data/spec/unit/resource/conditional_spec.rb +147 -0
- data/spec/unit/resource/cookbook_file_spec.rb +89 -0
- data/spec/unit/resource/cron_spec.rb +181 -0
- data/spec/unit/resource/csh_spec.rb +40 -0
- data/spec/unit/resource/deploy_revision_spec.rb +47 -0
- data/spec/unit/resource/deploy_spec.rb +259 -0
- data/spec/unit/resource/directory_spec.rb +82 -0
- data/spec/unit/resource/dpkg_package_spec.rb +38 -0
- data/spec/unit/resource/easy_install_package_spec.rb +48 -0
- data/spec/unit/resource/env_spec.rb +85 -0
- data/spec/unit/resource/erl_call_spec.rb +81 -0
- data/spec/unit/resource/execute_spec.rb +124 -0
- data/spec/unit/resource/file_spec.rb +121 -0
- data/spec/unit/resource/freebsd_package_spec.rb +39 -0
- data/spec/unit/resource/gem_package_spec.rb +49 -0
- data/spec/unit/resource/git_spec.rb +46 -0
- data/spec/unit/resource/group_spec.rb +148 -0
- data/spec/unit/resource/http_request_spec.rb +59 -0
- data/spec/unit/resource/ifconfig_spec.rb +46 -0
- data/spec/unit/resource/ips_package_spec.rb +43 -0
- data/spec/unit/resource/link_spec.rb +118 -0
- data/spec/unit/resource/log_spec.rb +61 -0
- data/spec/unit/resource/macports_package_spec.rb +37 -0
- data/spec/unit/resource/mdadm_spec.rb +102 -0
- data/spec/unit/resource/mount_spec.rb +158 -0
- data/spec/unit/resource/ohai_spec.rb +62 -0
- data/spec/unit/resource/package_spec.rb +80 -0
- data/spec/unit/resource/pacman_package_spec.rb +38 -0
- data/spec/unit/resource/perl_spec.rb +40 -0
- data/spec/unit/resource/portage_package_spec.rb +38 -0
- data/spec/unit/resource/python_spec.rb +40 -0
- data/spec/unit/resource/remote_directory_spec.rb +97 -0
- data/spec/unit/resource/remote_file_spec.rb +125 -0
- data/spec/unit/resource/route_spec.rb +107 -0
- data/spec/unit/resource/rpm_package_spec.rb +38 -0
- data/spec/unit/resource/ruby_block_spec.rb +57 -0
- data/spec/unit/resource/ruby_spec.rb +40 -0
- data/spec/unit/resource/scm_spec.rb +159 -0
- data/spec/unit/resource/script_spec.rb +69 -0
- data/spec/unit/resource/service_spec.rb +165 -0
- data/spec/unit/resource/smartos_package_spec.rb +38 -0
- data/spec/unit/resource/subversion_spec.rb +58 -0
- data/spec/unit/resource/template_spec.rb +108 -0
- data/spec/unit/resource/timestamped_deploy_spec.rb +28 -0
- data/spec/unit/resource/user_spec.rb +122 -0
- data/spec/unit/resource/yum_package_spec.rb +85 -0
- data/spec/unit/resource_collection/stepable_iterator_spec.rb +144 -0
- data/spec/unit/resource_collection_spec.rb +257 -0
- data/spec/unit/resource_definition_spec.rb +119 -0
- data/spec/unit/resource_platform_map_spec.rb +164 -0
- data/spec/unit/resource_reporter_spec.rb +591 -0
- data/spec/unit/resource_spec.rb +706 -0
- data/spec/unit/rest/auth_credentials_spec.rb +431 -0
- data/spec/unit/rest_spec.rb +644 -0
- data/spec/unit/role_spec.rb +275 -0
- data/spec/unit/run_context_spec.rb +64 -0
- data/spec/unit/run_list/run_list_expansion_spec.rb +129 -0
- data/spec/unit/run_list/run_list_item_spec.rb +117 -0
- data/spec/unit/run_list/versioned_recipe_list_spec.rb +123 -0
- data/spec/unit/run_list_spec.rb +521 -0
- data/spec/unit/run_status_spec.rb +145 -0
- data/spec/unit/runner_spec.rb +303 -0
- data/spec/unit/scan_access_control_spec.rb +182 -0
- data/spec/unit/search/query_spec.rb +99 -0
- data/spec/unit/shef/model_wrapper_spec.rb +97 -0
- data/spec/unit/shef/shef_ext_spec.rb +153 -0
- data/spec/unit/shef/shef_session_spec.rb +141 -0
- data/spec/unit/shef_spec.rb +161 -0
- data/spec/unit/solr_query/query_transform_spec.rb +454 -0
- data/spec/unit/solr_query/solr_http_request_spec.rb +244 -0
- data/spec/unit/solr_query_spec.rb +203 -0
- data/spec/unit/util/file_edit_spec.rb +135 -0
- data/spec/unit/version_class_spec.rb +172 -0
- data/spec/unit/version_constraint_spec.rb +134 -0
- data/spec/unit/webui_user_spec.rb +238 -0
- data/tasks/rspec.rb +75 -0
- metadata +978 -235
- data/VERSION +0 -1
- data/lib/chef/application.rb +0 -147
- data/lib/chef/application/solo.rb +0 -129
- data/lib/chef/applications.rb +0 -1
- data/lib/chef/checksum.rb +0 -103
- data/lib/chef/checksum/storage/filesystem.rb +0 -56
- data/lib/chef/checksum_cache.rb +0 -189
- data/lib/chef/client.rb +0 -295
- data/lib/chef/config.rb +0 -104
- data/lib/chef/cookbook/chefignore.rb +0 -66
- data/lib/chef/cookbook/cookbook_collection.rb +0 -45
- data/lib/chef/cookbook/cookbook_version_loader.rb +0 -160
- data/lib/chef/cookbook/file_system_file_vendor.rb +0 -56
- data/lib/chef/cookbook/file_vendor.rb +0 -48
- data/lib/chef/cookbook/metadata.rb +0 -629
- data/lib/chef/cookbook/syntax_check.rb +0 -136
- data/lib/chef/cookbook_loader.rb +0 -121
- data/lib/chef/cookbook_version.rb +0 -686
- data/lib/chef/cookbook_version_selector.rb +0 -149
- data/lib/chef/environment.rb +0 -231
- data/lib/chef/exceptions.rb +0 -150
- data/lib/chef/file_access_control.rb +0 -144
- data/lib/chef/file_cache.rb +0 -218
- data/lib/chef/handler.rb +0 -227
- data/lib/chef/handler/json_file.rb +0 -58
- data/lib/chef/json_compat.rb +0 -52
- data/lib/chef/mash.rb +0 -211
- data/lib/chef/mixin/command.rb +0 -163
- data/lib/chef/mixin/command/unix.rb +0 -215
- data/lib/chef/mixin/command/windows.rb +0 -76
- data/lib/chef/mixin/convert_to_class_name.rb +0 -63
- data/lib/chef/mixin/create_path.rb +0 -57
- data/lib/chef/mixin/deep_merge.rb +0 -225
- data/lib/chef/mixin/deprecation.rb +0 -65
- data/lib/chef/mixin/from_file.rb +0 -50
- data/lib/chef/mixin/get_source_from_package.rb +0 -42
- data/lib/chef/mixin/language.rb +0 -125
- data/lib/chef/mixin/language_include_attribute.rb +0 -61
- data/lib/chef/mixin/language_include_recipe.rb +0 -52
- data/lib/chef/mixin/params_validate.rb +0 -225
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +0 -78
- data/lib/chef/mixin/template.rb +0 -95
- data/lib/chef/mixin/xml_escape.rb +0 -140
- data/lib/chef/mixins.rb +0 -15
- data/lib/chef/monkey_patches/dir.rb +0 -36
- data/lib/chef/monkey_patches/numeric.rb +0 -15
- data/lib/chef/monkey_patches/object.rb +0 -9
- data/lib/chef/monkey_patches/regexp.rb +0 -34
- data/lib/chef/monkey_patches/tempfile.rb +0 -64
- data/lib/chef/nil_argument.rb +0 -3
- data/lib/chef/node.rb +0 -440
- data/lib/chef/node/attribute.rb +0 -487
- data/lib/chef/platform.rb +0 -218
- data/lib/chef/provider.rb +0 -124
- data/lib/chef/provider/cookbook_file.rb +0 -100
- data/lib/chef/provider/directory.rb +0 -72
- data/lib/chef/provider/execute.rb +0 -67
- data/lib/chef/provider/file.rb +0 -213
- data/lib/chef/provider/link.rb +0 -164
- data/lib/chef/provider/package/yum-dump.py +0 -286
- data/lib/chef/provider/remote_directory.rb +0 -136
- data/lib/chef/provider/template.rb +0 -104
- data/lib/chef/recipe.rb +0 -129
- data/lib/chef/resource.rb +0 -609
- data/lib/chef/resource/conditional.rb +0 -90
- data/lib/chef/resource/directory.rb +0 -89
- data/lib/chef/resource/env.rb +0 -58
- data/lib/chef/resource/execute.rb +0 -127
- data/lib/chef/resource/file.rb +0 -112
- data/lib/chef/resource/link.rb +0 -105
- data/lib/chef/resource/remote_directory.rb +0 -109
- data/lib/chef/resource/template.rb +0 -69
- data/lib/chef/resource_collection.rb +0 -217
- data/lib/chef/resource_collection/stepable_iterator.rb +0 -124
- data/lib/chef/resource_definition.rb +0 -67
- data/lib/chef/role.rb +0 -170
- data/lib/chef/run_context.rb +0 -126
- data/lib/chef/run_list.rb +0 -161
- data/lib/chef/run_list/run_list_expansion.rb +0 -159
- data/lib/chef/run_list/run_list_item.rb +0 -92
- data/lib/chef/run_list/versioned_recipe_list.rb +0 -68
- data/lib/chef/run_status.rb +0 -121
- data/lib/chef/runner.rb +0 -105
- data/lib/chef/shell_out.rb +0 -249
- data/lib/chef/shell_out/unix.rb +0 -223
- data/lib/chef/shell_out/windows.rb +0 -557
- data/lib/chef/tasks/chef_repo.rake +0 -334
- data/lib/chef/util/file_edit.rb +0 -122
- data/lib/chef/util/windows.rb +0 -56
- data/lib/chef/version_class.rb +0 -70
- data/lib/chef/version_constraint.rb +0 -116
@@ -0,0 +1,83 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Trevor O (trevoro@joyent.com)
|
3
|
+
# Copyright:: Copyright (c) 2012 Opscode
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "spec_helper"))
|
20
|
+
require 'ostruct'
|
21
|
+
|
22
|
+
describe Chef::Provider::Package::SmartOS, "load_current_resource" do
|
23
|
+
before(:each) do
|
24
|
+
@node = Chef::Node.new
|
25
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
26
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
27
|
+
@new_resource = Chef::Resource::Package.new("varnish")
|
28
|
+
@current_resource = Chef::Resource::Package.new("varnish")
|
29
|
+
|
30
|
+
|
31
|
+
@status = mock("Status", :exitstatus => 0)
|
32
|
+
@provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context)
|
33
|
+
Chef::Resource::Package.stub!(:new).and_return(@current_resource)
|
34
|
+
@stdin = StringIO.new
|
35
|
+
@stdout = "varnish-2.1.5nb2\n"
|
36
|
+
@stderr = StringIO.new
|
37
|
+
@pid = 10
|
38
|
+
@shell_out = OpenStruct.new(:stdout => @stdout, :stdin => @stdin, :stderr => @stderr, :status => @status, :exitstatus => 0)
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "when loading current resource" do
|
42
|
+
|
43
|
+
it "should create a current resource with the name of the new_resource" do
|
44
|
+
@provider.should_receive(:shell_out!).and_return(@shell_out)
|
45
|
+
Chef::Resource::Package.should_receive(:new).and_return(@current_resource)
|
46
|
+
@provider.load_current_resource
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should set the current resource package name" do
|
50
|
+
@provider.should_receive(:shell_out!).and_return(@shell_out)
|
51
|
+
@current_resource.should_receive(:package_name).with(@new_resource.package_name)
|
52
|
+
@provider.load_current_resource
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should set the installed version if it is installed" do
|
56
|
+
@provider.should_receive(:shell_out!).and_return(@shell_out)
|
57
|
+
@provider.load_current_resource
|
58
|
+
@current_resource.version.should == "2.1.5nb2"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should set the installed version to nil if it's not installed" do
|
62
|
+
out = OpenStruct.new(:stdout => nil)
|
63
|
+
@provider.should_receive(:shell_out!).and_return(out)
|
64
|
+
@provider.load_current_resource
|
65
|
+
@current_resource.version.should == nil
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "when manipulating a resource" do
|
72
|
+
|
73
|
+
it "run pkgin and install the package" do
|
74
|
+
out = OpenStruct.new(:stdout => nil)
|
75
|
+
@provider.should_receive(:shell_out!).with("pkg_info -E \"varnish*\"", {:env => nil, :returns=>[0,1]}).and_return(@shell_out)
|
76
|
+
@provider.should_receive(:shell_out!).with("pkgin -y install varnish-2.1.5nb2", {:env=>nil}).and_return(out)
|
77
|
+
@provider.load_current_resource
|
78
|
+
@provider.install_package("varnish", "2.1.5nb2")
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Toomas Pelberg (<toomasp@gmx.net>)
|
3
|
+
# Copyright:: Copyright (c) 2010 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
describe Chef::Provider::Package::Solaris do
|
21
|
+
before(:each) do
|
22
|
+
@node = Chef::Node.new
|
23
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
24
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
25
|
+
|
26
|
+
@new_resource = Chef::Resource::Package.new("SUNWbash")
|
27
|
+
@new_resource.source("/tmp/bash.pkg")
|
28
|
+
|
29
|
+
@provider = Chef::Provider::Package::Solaris.new(@new_resource, @run_context)
|
30
|
+
::File.stub!(:exists?).and_return(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "assessing the current package status" do
|
34
|
+
before do
|
35
|
+
@pkginfo =<<-PKGINFO
|
36
|
+
PKGINST: SUNWbash
|
37
|
+
NAME: GNU Bourne-Again shell (bash)
|
38
|
+
CATEGORY: system
|
39
|
+
ARCH: sparc
|
40
|
+
VERSION: 11.10.0,REV=2005.01.08.05.16
|
41
|
+
BASEDIR: /
|
42
|
+
VENDOR: Sun Microsystems, Inc.
|
43
|
+
DESC: GNU Bourne-Again shell (bash) version 3.0
|
44
|
+
PSTAMP: sfw10-patch20070430084444
|
45
|
+
INSTDATE: Nov 04 2009 01:02
|
46
|
+
HOTLINE: Please contact your local service provider
|
47
|
+
PKGINFO
|
48
|
+
|
49
|
+
@status = mock("Status", :exitstatus => 0)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should create a current resource with the name of new_resource" do
|
53
|
+
@provider.stub!(:popen4).and_return(@status)
|
54
|
+
@provider.load_current_resource
|
55
|
+
@provider.current_resource.name.should == "SUNWbash"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should set the current reource package name to the new resource package name" do
|
59
|
+
@provider.stub!(:popen4).and_return(@status)
|
60
|
+
@provider.load_current_resource
|
61
|
+
@provider.current_resource.package_name.should == "SUNWbash"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should raise an exception if a source is supplied but not found" do
|
65
|
+
@provider.stub!(:popen4).and_return(@status)
|
66
|
+
::File.stub!(:exists?).and_return(false)
|
67
|
+
@provider.define_resource_requirements
|
68
|
+
@provider.load_current_resource
|
69
|
+
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Package)
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
it "should get the source package version from pkginfo if provided" do
|
74
|
+
@stdout = StringIO.new(@pkginfo)
|
75
|
+
@stdin, @stderr = StringIO.new, StringIO.new
|
76
|
+
@provider.should_receive(:popen4).with("pkginfo -l -d /tmp/bash.pkg SUNWbash").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
77
|
+
@provider.should_receive(:popen4).with("pkginfo -l SUNWbash").and_return(@status)
|
78
|
+
@provider.load_current_resource
|
79
|
+
|
80
|
+
@provider.current_resource.package_name.should == "SUNWbash"
|
81
|
+
@new_resource.version.should == "11.10.0,REV=2005.01.08.05.16"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return the current version installed if found by pkginfo" do
|
85
|
+
@stdout = StringIO.new(@pkginfo)
|
86
|
+
@stdin, @stderr = StringIO.new, StringIO.new
|
87
|
+
@provider.should_receive(:popen4).with("pkginfo -l -d /tmp/bash.pkg SUNWbash").and_return(@status)
|
88
|
+
@provider.should_receive(:popen4).with("pkginfo -l SUNWbash").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
89
|
+
@provider.load_current_resource
|
90
|
+
@provider.current_resource.version.should == "11.10.0,REV=2005.01.08.05.16"
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should raise an exception if the source is not set but we are installing" do
|
94
|
+
@new_resource = Chef::Resource::Package.new("SUNWbash")
|
95
|
+
@provider = Chef::Provider::Package::Solaris.new(@new_resource, @run_context)
|
96
|
+
@provider.stub!(:popen4).and_return(@status)
|
97
|
+
lambda { @provider.run_action(:install) }.should raise_error(Chef::Exceptions::Package)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should raise an exception if pkginfo fails to run" do
|
101
|
+
@status = mock("Status", :exitstatus => -1)
|
102
|
+
@provider.stub!(:popen4).and_return(@status)
|
103
|
+
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should return a current resource with a nil version if the package is not found" do
|
107
|
+
@stdout = StringIO.new
|
108
|
+
@provider.should_receive(:popen4).with("pkginfo -l -d /tmp/bash.pkg SUNWbash").and_return(@status)
|
109
|
+
@provider.should_receive(:popen4).with("pkginfo -l SUNWbash").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
110
|
+
@provider.load_current_resource
|
111
|
+
@provider.current_resource.version.should be_nil
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "candidate_version" do
|
116
|
+
it "should return the candidate_version variable if already setup" do
|
117
|
+
@provider.candidate_version = "11.10.0,REV=2005.01.08.05.16"
|
118
|
+
@provider.should_not_receive(:popen4)
|
119
|
+
@provider.candidate_version
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should lookup the candidate_version if the variable is not already set" do
|
123
|
+
@status = mock("Status", :exitstatus => 0)
|
124
|
+
@provider.stub!(:popen4).and_return(@status)
|
125
|
+
@provider.should_receive(:popen4)
|
126
|
+
@provider.candidate_version
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should throw and exception if the exitstatus is not 0" do
|
130
|
+
@status = mock("Status", :exitstatus => 1)
|
131
|
+
@provider.stub!(:popen4).and_return(@status)
|
132
|
+
lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package)
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "install and upgrade" do
|
138
|
+
it "should run pkgadd -n -d with the package source to install" do
|
139
|
+
@provider.should_receive(:run_command_with_systems_locale).with({
|
140
|
+
:command => "pkgadd -n -d /tmp/bash.pkg all"
|
141
|
+
})
|
142
|
+
@provider.install_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should run pkgadd -n -d when the package is a path to install" do
|
146
|
+
@new_resource = Chef::Resource::Package.new("/tmp/bash.pkg")
|
147
|
+
@provider = Chef::Provider::Package::Solaris.new(@new_resource, @run_context)
|
148
|
+
@new_resource.source.should == "/tmp/bash.pkg"
|
149
|
+
@provider.should_receive(:run_command_with_systems_locale).with({
|
150
|
+
:command => "pkgadd -n -d /tmp/bash.pkg all"
|
151
|
+
})
|
152
|
+
@provider.install_package("/tmp/bash.pkg", "11.10.0,REV=2005.01.08.05.16")
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should run pkgadd -n -a /tmp/myadmin -d with the package options -a /tmp/myadmin" do
|
156
|
+
@new_resource.stub!(:options).and_return("-a /tmp/myadmin")
|
157
|
+
@provider.should_receive(:run_command_with_systems_locale).with({
|
158
|
+
:command => "pkgadd -n -a /tmp/myadmin -d /tmp/bash.pkg all"
|
159
|
+
})
|
160
|
+
@provider.install_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "remove" do
|
165
|
+
it "should run pkgrm -n to remove the package" do
|
166
|
+
@provider.should_receive(:run_command_with_systems_locale).with({
|
167
|
+
:command => "pkgrm -n SUNWbash"
|
168
|
+
})
|
169
|
+
@provider.remove_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should run pkgrm -n -a /tmp/myadmin with options -a /tmp/myadmin" do
|
173
|
+
@new_resource.stub!(:options).and_return("-a /tmp/myadmin")
|
174
|
+
@provider.should_receive(:run_command_with_systems_locale).with({
|
175
|
+
:command => "pkgrm -n -a /tmp/myadmin SUNWbash"
|
176
|
+
})
|
177
|
+
@provider.remove_package("SUNWbash", "11.10.0,REV=2005.01.08.05.16")
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
end
|
@@ -0,0 +1,1795 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
describe Chef::Provider::Package::Yum do
|
22
|
+
before(:each) do
|
23
|
+
@node = Chef::Node.new
|
24
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
25
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
26
|
+
@new_resource = Chef::Resource::Package.new('cups')
|
27
|
+
@status = mock("Status", :exitstatus => 0)
|
28
|
+
@yum_cache = mock(
|
29
|
+
'Chef::Provider::Yum::YumCache',
|
30
|
+
:reload_installed => true,
|
31
|
+
:reset => true,
|
32
|
+
:installed_version => "1.2.4-11.18.el5",
|
33
|
+
:candidate_version => "1.2.4-11.18.el5_2.3",
|
34
|
+
:package_available? => true,
|
35
|
+
:version_available? => true,
|
36
|
+
:allow_multi_install => [ "kernel" ],
|
37
|
+
:package_repository => "base"
|
38
|
+
)
|
39
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
40
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
41
|
+
@stderr = StringIO.new
|
42
|
+
@pid = mock("PID")
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when loading the current system state" do
|
46
|
+
it "should create a current resource with the name of the new_resource" do
|
47
|
+
@provider.load_current_resource
|
48
|
+
@provider.current_resource.name.should == "cups"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should set the current resources package name to the new resources package name" do
|
52
|
+
@provider.load_current_resource
|
53
|
+
@provider.current_resource.package_name.should == "cups"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should set the installed version to nil on the current resource if no installed package" do
|
57
|
+
@yum_cache.stub!(:installed_version).and_return(nil)
|
58
|
+
@provider.load_current_resource
|
59
|
+
@provider.current_resource.version.should be_nil
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should set the installed version if yum has one" do
|
63
|
+
@provider.load_current_resource
|
64
|
+
@provider.current_resource.version.should == "1.2.4-11.18.el5"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should set the candidate version if yum info has one" do
|
68
|
+
@provider.load_current_resource
|
69
|
+
@provider.candidate_version.should eql("1.2.4-11.18.el5_2.3")
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should return the current resouce" do
|
73
|
+
@provider.load_current_resource.should eql(@provider.current_resource)
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "when arch in package_name" do
|
77
|
+
it "should set the arch if no existing package_name is found and new_package_name+new_arch is available" do
|
78
|
+
@new_resource = Chef::Resource::YumPackage.new('testing.noarch')
|
79
|
+
@yum_cache = mock(
|
80
|
+
'Chef::Provider::Yum::YumCache'
|
81
|
+
)
|
82
|
+
@yum_cache.stub!(:installed_version) do |package_name, arch|
|
83
|
+
# nothing installed for package_name/new_package_name
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
@yum_cache.stub!(:candidate_version) do |package_name, arch|
|
87
|
+
if package_name == "testing.noarch" || package_name == "testing.more.noarch"
|
88
|
+
nil
|
89
|
+
# candidate for new_package_name
|
90
|
+
elsif package_name == "testing" || package_name == "testing.more"
|
91
|
+
"1.1"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
@yum_cache.stub!(:package_available?).and_return(true)
|
95
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
96
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
97
|
+
@provider.load_current_resource
|
98
|
+
@provider.new_resource.package_name.should == "testing"
|
99
|
+
@provider.new_resource.arch.should == "noarch"
|
100
|
+
@provider.arch.should == "noarch"
|
101
|
+
|
102
|
+
@new_resource = Chef::Resource::YumPackage.new('testing.more.noarch')
|
103
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
104
|
+
@provider.load_current_resource
|
105
|
+
@provider.new_resource.package_name.should == "testing.more"
|
106
|
+
@provider.new_resource.arch.should == "noarch"
|
107
|
+
@provider.arch.should == "noarch"
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should not set the arch when an existing package_name is found" do
|
111
|
+
@new_resource = Chef::Resource::YumPackage.new('testing.beta3')
|
112
|
+
@yum_cache = mock(
|
113
|
+
'Chef::Provider::Yum::YumCache'
|
114
|
+
)
|
115
|
+
@yum_cache.stub!(:installed_version) do |package_name, arch|
|
116
|
+
# installed for package_name
|
117
|
+
if package_name == "testing.beta3" || package_name == "testing.beta3.more"
|
118
|
+
"1.1"
|
119
|
+
elsif package_name == "testing" || package_name == "testing.beta3"
|
120
|
+
nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
@yum_cache.stub!(:candidate_version) do |package_name, arch|
|
124
|
+
# no candidate for package_name/new_package_name
|
125
|
+
nil
|
126
|
+
end
|
127
|
+
@yum_cache.stub!(:package_available?).and_return(true)
|
128
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
129
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
130
|
+
# annoying side effect of the fun stub'ing above
|
131
|
+
@provider.load_current_resource
|
132
|
+
@provider.new_resource.package_name.should == "testing.beta3"
|
133
|
+
@provider.new_resource.arch.should == nil
|
134
|
+
@provider.arch.should == nil
|
135
|
+
|
136
|
+
@new_resource = Chef::Resource::YumPackage.new('testing.beta3.more')
|
137
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
138
|
+
@provider.load_current_resource
|
139
|
+
@provider.new_resource.package_name.should == "testing.beta3.more"
|
140
|
+
@provider.new_resource.arch.should == nil
|
141
|
+
@provider.arch.should == nil
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should not set the arch when no existing package_name or new_package_name+new_arch is found" do
|
145
|
+
@new_resource = Chef::Resource::YumPackage.new('testing.beta3')
|
146
|
+
@yum_cache = mock(
|
147
|
+
'Chef::Provider::Yum::YumCache'
|
148
|
+
)
|
149
|
+
@yum_cache.stub!(:installed_version) do |package_name, arch|
|
150
|
+
# nothing installed for package_name/new_package_name
|
151
|
+
nil
|
152
|
+
end
|
153
|
+
@yum_cache.stub!(:candidate_version) do |package_name, arch|
|
154
|
+
# no candidate for package_name/new_package_name
|
155
|
+
nil
|
156
|
+
end
|
157
|
+
@yum_cache.stub!(:package_available?).and_return(true)
|
158
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
159
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
160
|
+
@provider.load_current_resource
|
161
|
+
@provider.new_resource.package_name.should == "testing.beta3"
|
162
|
+
@provider.new_resource.arch.should == nil
|
163
|
+
@provider.arch.should == nil
|
164
|
+
|
165
|
+
@new_resource = Chef::Resource::YumPackage.new('testing.beta3.more')
|
166
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
167
|
+
@provider.load_current_resource
|
168
|
+
@provider.new_resource.package_name.should == "testing.beta3.more"
|
169
|
+
@provider.new_resource.arch.should == nil
|
170
|
+
@provider.arch.should == nil
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should ensure it doesn't clobber an existing arch if passed" do
|
174
|
+
@new_resource = Chef::Resource::YumPackage.new('testing.i386')
|
175
|
+
@new_resource.arch("x86_64")
|
176
|
+
@yum_cache = mock(
|
177
|
+
'Chef::Provider::Yum::YumCache'
|
178
|
+
)
|
179
|
+
@yum_cache.stub!(:installed_version) do |package_name, arch|
|
180
|
+
# nothing installed for package_name/new_package_name
|
181
|
+
nil
|
182
|
+
end
|
183
|
+
@yum_cache.stub!(:candidate_version) do |package_name, arch|
|
184
|
+
if package_name == "testing.noarch"
|
185
|
+
nil
|
186
|
+
# candidate for new_package_name
|
187
|
+
elsif package_name == "testing"
|
188
|
+
"1.1"
|
189
|
+
end
|
190
|
+
end.and_return("something")
|
191
|
+
@yum_cache.stub!(:package_available?).and_return(true)
|
192
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
193
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
194
|
+
@provider.load_current_resource
|
195
|
+
@provider.new_resource.package_name.should == "testing.i386"
|
196
|
+
@provider.new_resource.arch.should == "x86_64"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should flush the cache if :before is true" do
|
201
|
+
@new_resource.stub!(:flush_cache).and_return({:after => false, :before => true})
|
202
|
+
@yum_cache.should_receive(:reload).once
|
203
|
+
@provider.load_current_resource
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should flush the cache if :before is false" do
|
207
|
+
@new_resource.stub!(:flush_cache).and_return({:after => false, :before => false})
|
208
|
+
@yum_cache.should_not_receive(:reload)
|
209
|
+
@provider.load_current_resource
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should search provides if package name can't be found then set package_name to match" do
|
213
|
+
@yum_cache = mock(
|
214
|
+
'Chef::Provider::Yum::YumCache',
|
215
|
+
:reload_installed => true,
|
216
|
+
:reset => true,
|
217
|
+
:installed_version => "1.2.4-11.18.el5",
|
218
|
+
:candidate_version => "1.2.4-11.18.el5",
|
219
|
+
:package_available? => false,
|
220
|
+
:version_available? => true
|
221
|
+
)
|
222
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
223
|
+
pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "1.2.4-11.18.el5", "x86_64", [])
|
224
|
+
@yum_cache.should_receive(:packages_from_require).and_return([pkg])
|
225
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
226
|
+
@provider.load_current_resource
|
227
|
+
@new_resource.package_name.should == "test-package"
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should search provides if package name can't be found, warn about multiple matches, but use the first one" do
|
231
|
+
@yum_cache = mock(
|
232
|
+
'Chef::Provider::Yum::YumCache',
|
233
|
+
:reload_installed => true,
|
234
|
+
:reset => true,
|
235
|
+
:installed_version => "1.2.4-11.18.el5",
|
236
|
+
:candidate_version => "1.2.4-11.18.el5",
|
237
|
+
:package_available? => false,
|
238
|
+
:version_available? => true
|
239
|
+
)
|
240
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
241
|
+
pkg_x = Chef::Provider::Package::Yum::RPMPackage.new("test-package-x", "1.2.4-11.18.el5", "x86_64", [])
|
242
|
+
pkg_y = Chef::Provider::Package::Yum::RPMPackage.new("test-package-y", "1.2.6-11.3.el5", "i386", [])
|
243
|
+
@yum_cache.should_receive(:packages_from_require).and_return([pkg_x, pkg_y])
|
244
|
+
Chef::Log.should_receive(:warn).exactly(1).times.with(%r{matched multiple Provides})
|
245
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
246
|
+
@provider.load_current_resource
|
247
|
+
@new_resource.package_name.should == "test-package-x"
|
248
|
+
end
|
249
|
+
|
250
|
+
it "should search provides if no package is available - if no match in installed provides then load the complete set" do
|
251
|
+
@yum_cache = mock(
|
252
|
+
'Chef::Provider::Yum::YumCache',
|
253
|
+
:reload_installed => true,
|
254
|
+
:reset => true,
|
255
|
+
:installed_version => "1.2.4-11.18.el5",
|
256
|
+
:candidate_version => "1.2.4-11.18.el5",
|
257
|
+
:package_available? => false,
|
258
|
+
:version_available? => true
|
259
|
+
)
|
260
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
261
|
+
@yum_cache.should_receive(:packages_from_require).twice.and_return([])
|
262
|
+
@yum_cache.should_receive(:reload_provides)
|
263
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
264
|
+
@provider.load_current_resource
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should search provides if no package is available and not load the complete set if action is :remove or :purge" do
|
268
|
+
@yum_cache = mock(
|
269
|
+
'Chef::Provider::Yum::YumCache',
|
270
|
+
:reload_installed => true,
|
271
|
+
:reset => true,
|
272
|
+
:installed_version => "1.2.4-11.18.el5",
|
273
|
+
:candidate_version => "1.2.4-11.18.el5",
|
274
|
+
:package_available? => false,
|
275
|
+
:version_available? => true
|
276
|
+
)
|
277
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
278
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
279
|
+
@yum_cache.should_receive(:packages_from_require).once.and_return([])
|
280
|
+
@yum_cache.should_not_receive(:reload_provides)
|
281
|
+
@new_resource.action(:remove)
|
282
|
+
@provider.load_current_resource
|
283
|
+
@yum_cache.should_receive(:packages_from_require).once.and_return([])
|
284
|
+
@yum_cache.should_not_receive(:reload_provides)
|
285
|
+
@new_resource.action(:purge)
|
286
|
+
@provider.load_current_resource
|
287
|
+
end
|
288
|
+
|
289
|
+
it "should search provides if no package is available - if no match in provides leave the name intact" do
|
290
|
+
@yum_cache = mock(
|
291
|
+
'Chef::Provider::Yum::YumCache',
|
292
|
+
:reload_provides => true,
|
293
|
+
:reload_installed => true,
|
294
|
+
:reset => true,
|
295
|
+
:installed_version => "1.2.4-11.18.el5",
|
296
|
+
:candidate_version => "1.2.4-11.18.el5",
|
297
|
+
:package_available? => false,
|
298
|
+
:version_available? => true
|
299
|
+
)
|
300
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
301
|
+
@yum_cache.should_receive(:packages_from_require).twice.and_return([])
|
302
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
303
|
+
@provider.load_current_resource
|
304
|
+
@new_resource.package_name.should == "cups"
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
describe "when installing a package" do
|
309
|
+
it "should run yum install with the package name and version" do
|
310
|
+
@provider.load_current_resource
|
311
|
+
Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
|
312
|
+
@provider.should_receive(:yum_command).with(
|
313
|
+
"yum -d0 -e0 -y install emacs-1.0"
|
314
|
+
)
|
315
|
+
@provider.install_package("emacs", "1.0")
|
316
|
+
end
|
317
|
+
|
318
|
+
it "should run yum localinstall if given a path to an rpm" do
|
319
|
+
@new_resource.stub!(:source).and_return("/tmp/emacs-21.4-20.el5.i386.rpm")
|
320
|
+
@provider.should_receive(:yum_command).with(
|
321
|
+
"yum -d0 -e0 -y localinstall /tmp/emacs-21.4-20.el5.i386.rpm"
|
322
|
+
)
|
323
|
+
@provider.install_package("emacs", "21.4-20.el5")
|
324
|
+
end
|
325
|
+
|
326
|
+
it "should run yum localinstall if given a path to an rpm as the package" do
|
327
|
+
@new_resource = Chef::Resource::Package.new("/tmp/emacs-21.4-20.el5.i386.rpm")
|
328
|
+
::File.stub!(:exists?).and_return(true)
|
329
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
330
|
+
@new_resource.source.should == "/tmp/emacs-21.4-20.el5.i386.rpm"
|
331
|
+
@provider.should_receive(:yum_command).with(
|
332
|
+
"yum -d0 -e0 -y localinstall /tmp/emacs-21.4-20.el5.i386.rpm"
|
333
|
+
)
|
334
|
+
@provider.install_package("/tmp/emacs-21.4-20.el5.i386.rpm", "21.4-20.el5")
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should run yum install with the package name, version and arch" do
|
338
|
+
@provider.load_current_resource
|
339
|
+
@new_resource.stub!(:arch).and_return("i386")
|
340
|
+
Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
|
341
|
+
@provider.should_receive(:yum_command).with(
|
342
|
+
"yum -d0 -e0 -y install emacs-21.4-20.el5.i386"
|
343
|
+
)
|
344
|
+
@provider.install_package("emacs", "21.4-20.el5")
|
345
|
+
end
|
346
|
+
|
347
|
+
it "installs the package with the options given in the resource" do
|
348
|
+
@provider.load_current_resource
|
349
|
+
@provider.candidate_version = '11'
|
350
|
+
@new_resource.stub!(:options).and_return("--disablerepo epmd")
|
351
|
+
Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
|
352
|
+
@provider.should_receive(:yum_command).with(
|
353
|
+
"yum -d0 -e0 -y --disablerepo epmd install cups-11"
|
354
|
+
)
|
355
|
+
@provider.install_package(@new_resource.name, @provider.candidate_version)
|
356
|
+
end
|
357
|
+
|
358
|
+
it "should raise an exception if the package is not available" do
|
359
|
+
@yum_cache = mock(
|
360
|
+
'Chef::Provider::Yum::YumCache',
|
361
|
+
:reload_from_cache => true,
|
362
|
+
:reset => true,
|
363
|
+
:installed_version => "1.2.4-11.18.el5",
|
364
|
+
:candidate_version => "1.2.4-11.18.el5_2.3",
|
365
|
+
:package_available? => true,
|
366
|
+
:version_available? => nil
|
367
|
+
)
|
368
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
369
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
370
|
+
lambda { @provider.install_package("lolcats", "0.99") }.should raise_error(Chef::Exceptions::Package, %r{Version .* not found})
|
371
|
+
end
|
372
|
+
|
373
|
+
it "should raise an exception if candidate version is older than the installed version and allow_downgrade is false" do
|
374
|
+
@new_resource.stub!(:allow_downgrade).and_return(false)
|
375
|
+
@yum_cache = mock(
|
376
|
+
'Chef::Provider::Yum::YumCache',
|
377
|
+
:reload_installed => true,
|
378
|
+
:reset => true,
|
379
|
+
:installed_version => "1.2.4-11.18.el5",
|
380
|
+
:candidate_version => "1.2.4-11.15.el5",
|
381
|
+
:package_available? => true,
|
382
|
+
:version_available? => true,
|
383
|
+
:allow_multi_install => [ "kernel" ]
|
384
|
+
)
|
385
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
386
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
387
|
+
@provider.load_current_resource
|
388
|
+
lambda { @provider.install_package("cups", "1.2.4-11.15.el5") }.should raise_error(Chef::Exceptions::Package, %r{is newer than candidate package})
|
389
|
+
end
|
390
|
+
|
391
|
+
it "should not raise an exception if candidate version is older than the installed version and the package is list in yum's installonlypkg option" do
|
392
|
+
@yum_cache = mock(
|
393
|
+
'Chef::Provider::Yum::YumCache',
|
394
|
+
:reload_installed => true,
|
395
|
+
:reset => true,
|
396
|
+
:installed_version => "1.2.4-11.18.el5",
|
397
|
+
:candidate_version => "1.2.4-11.15.el5",
|
398
|
+
:package_available? => true,
|
399
|
+
:version_available? => true,
|
400
|
+
:allow_multi_install => [ "cups" ],
|
401
|
+
:package_repository => "base"
|
402
|
+
)
|
403
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
404
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
405
|
+
@provider.load_current_resource
|
406
|
+
@provider.should_receive(:yum_command).with(
|
407
|
+
"yum -d0 -e0 -y install cups-1.2.4-11.15.el5"
|
408
|
+
)
|
409
|
+
@provider.install_package("cups", "1.2.4-11.15.el5")
|
410
|
+
end
|
411
|
+
|
412
|
+
it "should run yum downgrade if candidate version is older than the installed version and allow_downgrade is true" do
|
413
|
+
@new_resource.stub!(:allow_downgrade).and_return(true)
|
414
|
+
@yum_cache = mock(
|
415
|
+
'Chef::Provider::Yum::YumCache',
|
416
|
+
:reload_installed => true,
|
417
|
+
:reset => true,
|
418
|
+
:installed_version => "1.2.4-11.18.el5",
|
419
|
+
:candidate_version => "1.2.4-11.15.el5",
|
420
|
+
:package_available? => true,
|
421
|
+
:version_available? => true,
|
422
|
+
:allow_multi_install => [],
|
423
|
+
:package_repository => "base"
|
424
|
+
)
|
425
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
426
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
427
|
+
@provider.load_current_resource
|
428
|
+
@provider.should_receive(:yum_command).with(
|
429
|
+
"yum -d0 -e0 -y downgrade cups-1.2.4-11.15.el5"
|
430
|
+
)
|
431
|
+
@provider.install_package("cups", "1.2.4-11.15.el5")
|
432
|
+
end
|
433
|
+
|
434
|
+
it "should run yum install then flush the cache if :after is true" do
|
435
|
+
@new_resource.stub!(:flush_cache).and_return({:after => true, :before => false})
|
436
|
+
@provider.load_current_resource
|
437
|
+
Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
|
438
|
+
@provider.should_receive(:yum_command).with(
|
439
|
+
"yum -d0 -e0 -y install emacs-1.0"
|
440
|
+
)
|
441
|
+
@yum_cache.should_receive(:reload).once
|
442
|
+
@provider.install_package("emacs", "1.0")
|
443
|
+
end
|
444
|
+
|
445
|
+
it "should run yum install then not flush the cache if :after is false" do
|
446
|
+
@new_resource.stub!(:flush_cache).and_return({:after => false, :before => false})
|
447
|
+
@provider.load_current_resource
|
448
|
+
Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
|
449
|
+
@provider.should_receive(:yum_command).with(
|
450
|
+
"yum -d0 -e0 -y install emacs-1.0"
|
451
|
+
)
|
452
|
+
@yum_cache.should_not_receive(:reload)
|
453
|
+
@provider.install_package("emacs", "1.0")
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
describe "when upgrading a package" do
|
458
|
+
it "should run yum install if the package is installed and a version is given" do
|
459
|
+
@provider.load_current_resource
|
460
|
+
@provider.candidate_version = '11'
|
461
|
+
Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
|
462
|
+
@provider.should_receive(:yum_command).with(
|
463
|
+
"yum -d0 -e0 -y install cups-11"
|
464
|
+
)
|
465
|
+
@provider.upgrade_package(@new_resource.name, @provider.candidate_version)
|
466
|
+
end
|
467
|
+
|
468
|
+
it "should run yum install if the package is not installed" do
|
469
|
+
@provider.load_current_resource
|
470
|
+
@current_resource = Chef::Resource::Package.new('cups')
|
471
|
+
@provider.candidate_version = '11'
|
472
|
+
Chef::Provider::Package::Yum::RPMUtils.stub!(:rpmvercmp).and_return(-1)
|
473
|
+
@provider.should_receive(:yum_command).with(
|
474
|
+
"yum -d0 -e0 -y install cups-11"
|
475
|
+
)
|
476
|
+
@provider.upgrade_package(@new_resource.name, @provider.candidate_version)
|
477
|
+
end
|
478
|
+
|
479
|
+
it "should raise an exception if candidate version is older than the installed version" do
|
480
|
+
@yum_cache = mock(
|
481
|
+
'Chef::Provider::Yum::YumCache',
|
482
|
+
:reload_installed => true,
|
483
|
+
:reset => true,
|
484
|
+
:installed_version => "1.2.4-11.18.el5",
|
485
|
+
:candidate_version => "1.2.4-11.15.el5",
|
486
|
+
:package_available? => true,
|
487
|
+
:version_available? => true,
|
488
|
+
:allow_multi_install => [ "kernel" ]
|
489
|
+
)
|
490
|
+
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
|
491
|
+
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
|
492
|
+
@provider.load_current_resource
|
493
|
+
lambda { @provider.upgrade_package("cups", "1.2.4-11.15.el5") }.should raise_error(Chef::Exceptions::Package, %r{is newer than candidate package})
|
494
|
+
end
|
495
|
+
|
496
|
+
# Test our little workaround, some crossover into Chef::Provider::Package territory
|
497
|
+
it "should call action_upgrade in the parent if the current resource version is nil" do
|
498
|
+
@yum_cache.stub!(:installed_version).and_return(nil)
|
499
|
+
@provider.load_current_resource
|
500
|
+
@current_resource = Chef::Resource::Package.new('cups')
|
501
|
+
@provider.candidate_version = '11'
|
502
|
+
@provider.should_receive(:upgrade_package).with(
|
503
|
+
"cups",
|
504
|
+
"11"
|
505
|
+
)
|
506
|
+
@provider.action_upgrade
|
507
|
+
@provider.converge
|
508
|
+
end
|
509
|
+
|
510
|
+
it "should call action_upgrade in the parent if the candidate version is nil" do
|
511
|
+
@provider.load_current_resource
|
512
|
+
@current_resource = Chef::Resource::Package.new('cups')
|
513
|
+
@provider.candidate_version = nil
|
514
|
+
@provider.should_not_receive(:upgrade_package)
|
515
|
+
@provider.action_upgrade
|
516
|
+
@provider.converge
|
517
|
+
end
|
518
|
+
|
519
|
+
it "should call action_upgrade in the parent if the candidate is newer" do
|
520
|
+
@provider.load_current_resource
|
521
|
+
@current_resource = Chef::Resource::Package.new('cups')
|
522
|
+
@provider.candidate_version = '11'
|
523
|
+
@provider.should_receive(:upgrade_package).with(
|
524
|
+
"cups",
|
525
|
+
"11"
|
526
|
+
)
|
527
|
+
@provider.action_upgrade
|
528
|
+
@provider.converge
|
529
|
+
end
|
530
|
+
|
531
|
+
it "should not call action_upgrade in the parent if the candidate is older" do
|
532
|
+
@yum_cache.stub!(:installed_version).and_return("12")
|
533
|
+
@provider.load_current_resource
|
534
|
+
@current_resource = Chef::Resource::Package.new('cups')
|
535
|
+
@provider.candidate_version = '11'
|
536
|
+
@provider.should_not_receive(:upgrade_package)
|
537
|
+
@provider.action_upgrade
|
538
|
+
@provider.converge
|
539
|
+
end
|
540
|
+
end
|
541
|
+
|
542
|
+
describe "when removing a package" do
|
543
|
+
it "should run yum remove with the package name" do
|
544
|
+
@provider.should_receive(:yum_command).with(
|
545
|
+
"yum -d0 -e0 -y remove emacs-1.0"
|
546
|
+
)
|
547
|
+
@provider.remove_package("emacs", "1.0")
|
548
|
+
end
|
549
|
+
|
550
|
+
it "should run yum remove with the package name and arch" do
|
551
|
+
@new_resource.stub!(:arch).and_return("x86_64")
|
552
|
+
@provider.should_receive(:yum_command).with(
|
553
|
+
"yum -d0 -e0 -y remove emacs-1.0.x86_64"
|
554
|
+
)
|
555
|
+
@provider.remove_package("emacs", "1.0")
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
describe "when purging a package" do
|
560
|
+
it "should run yum remove with the package name" do
|
561
|
+
@provider.should_receive(:yum_command).with(
|
562
|
+
"yum -d0 -e0 -y remove emacs-1.0"
|
563
|
+
)
|
564
|
+
@provider.purge_package("emacs", "1.0")
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
describe "when running yum" do
|
569
|
+
it "should run yum once if it exits with a return code of 0" do
|
570
|
+
@status = mock("Status", :exitstatus => 0)
|
571
|
+
@provider.stub!(:output_of_command).and_return([@status, "", ""])
|
572
|
+
@provider.should_receive(:output_of_command).once.with(
|
573
|
+
"yum -d0 -e0 -y install emacs-1.0",
|
574
|
+
{}
|
575
|
+
)
|
576
|
+
@provider.yum_command("yum -d0 -e0 -y install emacs-1.0")
|
577
|
+
end
|
578
|
+
|
579
|
+
it "should run yum once if it exits with a return code > 0 and no scriptlet failures" do
|
580
|
+
@status = mock("Status", :exitstatus => 2)
|
581
|
+
@provider.stub!(:output_of_command).and_return([@status, "failure failure", "problem problem"])
|
582
|
+
@provider.should_receive(:output_of_command).once.with(
|
583
|
+
"yum -d0 -e0 -y install emacs-1.0",
|
584
|
+
{}
|
585
|
+
)
|
586
|
+
lambda { @provider.yum_command("yum -d0 -e0 -y install emacs-1.0") }.should raise_error(Chef::Exceptions::Exec)
|
587
|
+
end
|
588
|
+
|
589
|
+
it "should run yum once if it exits with a return code of 1 and %pre scriptlet failures" do
|
590
|
+
@status = mock("Status", :exitstatus => 1)
|
591
|
+
@provider.stub!(:output_of_command).and_return([@status, "error: %pre(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""])
|
592
|
+
@provider.should_receive(:output_of_command).once.with(
|
593
|
+
"yum -d0 -e0 -y install emacs-1.0",
|
594
|
+
{}
|
595
|
+
)
|
596
|
+
# will still raise an exception, can't stub out the subsequent call
|
597
|
+
lambda { @provider.yum_command("yum -d0 -e0 -y install emacs-1.0") }.should raise_error(Chef::Exceptions::Exec)
|
598
|
+
end
|
599
|
+
|
600
|
+
it "should run yum twice if it exits with a return code of 1 and %post scriptlet failures" do
|
601
|
+
@status = mock("Status", :exitstatus => 1)
|
602
|
+
@provider.stub!(:output_of_command).and_return([@status, "error: %post(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""])
|
603
|
+
@provider.should_receive(:output_of_command).twice.with(
|
604
|
+
"yum -d0 -e0 -y install emacs-1.0",
|
605
|
+
{}
|
606
|
+
)
|
607
|
+
# will still raise an exception, can't stub out the subsequent call
|
608
|
+
lambda { @provider.yum_command("yum -d0 -e0 -y install emacs-1.0") }.should raise_error(Chef::Exceptions::Exec)
|
609
|
+
end
|
610
|
+
end
|
611
|
+
end
|
612
|
+
|
613
|
+
describe Chef::Provider::Package::Yum::RPMUtils do
|
614
|
+
describe "version_parse" do
|
615
|
+
before do
|
616
|
+
@rpmutils = Chef::Provider::Package::Yum::RPMUtils
|
617
|
+
end
|
618
|
+
|
619
|
+
it "parses known good epoch strings" do
|
620
|
+
[
|
621
|
+
[ "0:3.3", [ 0, "3.3", nil ] ],
|
622
|
+
[ "9:1.7.3", [ 9, "1.7.3", nil ] ],
|
623
|
+
[ "15:20020927", [ 15, "20020927", nil ] ]
|
624
|
+
].each do |x, y|
|
625
|
+
@rpmutils.version_parse(x).should == y
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
it "parses strange epoch strings" do
|
630
|
+
[
|
631
|
+
[ ":3.3", [ 0, "3.3", nil ] ],
|
632
|
+
[ "-1:1.7.3", [ nil, nil, "1:1.7.3" ] ],
|
633
|
+
[ "-:20020927", [ nil, nil, ":20020927" ] ]
|
634
|
+
].each do |x, y|
|
635
|
+
@rpmutils.version_parse(x).should == y
|
636
|
+
end
|
637
|
+
end
|
638
|
+
|
639
|
+
it "parses known good version strings" do
|
640
|
+
[
|
641
|
+
[ "3.3", [ nil, "3.3", nil ] ],
|
642
|
+
[ "1.7.3", [ nil, "1.7.3", nil ] ],
|
643
|
+
[ "20020927", [ nil, "20020927", nil ] ]
|
644
|
+
].each do |x, y|
|
645
|
+
@rpmutils.version_parse(x).should == y
|
646
|
+
end
|
647
|
+
end
|
648
|
+
|
649
|
+
it "parses strange version strings" do
|
650
|
+
[
|
651
|
+
[ "3..3", [ nil, "3..3", nil ] ],
|
652
|
+
[ "0001.7.3", [ nil, "0001.7.3", nil ] ],
|
653
|
+
[ "20020927,3", [ nil, "20020927,3", nil ] ]
|
654
|
+
].each do |x, y|
|
655
|
+
@rpmutils.version_parse(x).should == y
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
it "parses known good version release strings" do
|
660
|
+
[
|
661
|
+
[ "3.3-0.pre3.1.60.el5_5.1", [ nil, "3.3", "0.pre3.1.60.el5_5.1" ] ],
|
662
|
+
[ "1.7.3-1jpp.2.el5", [ nil, "1.7.3", "1jpp.2.el5" ] ],
|
663
|
+
[ "20020927-46.el5", [ nil, "20020927", "46.el5" ] ]
|
664
|
+
].each do |x, y|
|
665
|
+
@rpmutils.version_parse(x).should == y
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
669
|
+
it "parses strange version release strings" do
|
670
|
+
[
|
671
|
+
[ "3.3-", [ nil, "3.3", nil ] ],
|
672
|
+
[ "-1jpp.2.el5", [ nil, nil, "1jpp.2.el5" ] ],
|
673
|
+
[ "-0020020927-46.el5", [ nil, "-0020020927", "46.el5" ] ]
|
674
|
+
].each do |x, y|
|
675
|
+
@rpmutils.version_parse(x).should == y
|
676
|
+
end
|
677
|
+
end
|
678
|
+
end
|
679
|
+
|
680
|
+
describe "rpmvercmp" do
|
681
|
+
before do
|
682
|
+
@rpmutils = Chef::Provider::Package::Yum::RPMUtils
|
683
|
+
end
|
684
|
+
|
685
|
+
it "should validate version compare logic for standard examples" do
|
686
|
+
[
|
687
|
+
# numeric
|
688
|
+
[ "0.0.2", "0.0.1", 1 ],
|
689
|
+
[ "0.2.0", "0.1.0", 1 ],
|
690
|
+
[ "2.0.0", "1.0.0", 1 ],
|
691
|
+
[ "0.0.1", "0.0.1", 0 ],
|
692
|
+
[ "0.0.1", "0.0.2", -1 ],
|
693
|
+
[ "0.1.0", "0.2.0", -1 ],
|
694
|
+
[ "1.0.0", "2.0.0", -1 ],
|
695
|
+
# alpha
|
696
|
+
[ "bb", "aa", 1 ],
|
697
|
+
[ "ab", "aa", 1 ],
|
698
|
+
[ "aa", "aa", 0 ],
|
699
|
+
[ "aa", "bb", -1 ],
|
700
|
+
[ "aa", "ab", -1 ],
|
701
|
+
[ "BB", "AA", 1 ],
|
702
|
+
[ "AA", "AA", 0 ],
|
703
|
+
[ "AA", "BB", -1 ],
|
704
|
+
[ "aa", "AA", 1 ],
|
705
|
+
[ "AA", "aa", -1 ],
|
706
|
+
# alphanumeric
|
707
|
+
[ "0.0.1b", "0.0.1a", 1 ],
|
708
|
+
[ "0.1b.0", "0.1a.0", 1 ],
|
709
|
+
[ "1b.0.0", "1a.0.0", 1 ],
|
710
|
+
[ "0.0.1a", "0.0.1a", 0 ],
|
711
|
+
[ "0.0.1a", "0.0.1b", -1 ],
|
712
|
+
[ "0.1a.0", "0.1b.0", -1 ],
|
713
|
+
[ "1a.0.0", "1b.0.0", -1 ],
|
714
|
+
# alphanumeric against alphanumeric
|
715
|
+
[ "0.0.1", "0.0.a", 1 ],
|
716
|
+
[ "0.1.0", "0.a.0", 1 ],
|
717
|
+
[ "1.0.0", "a.0.0", 1 ],
|
718
|
+
[ "0.0.a", "0.0.a", 0 ],
|
719
|
+
[ "0.0.a", "0.0.1", -1 ],
|
720
|
+
[ "0.a.0", "0.1.0", -1 ],
|
721
|
+
[ "a.0.0", "1.0.0", -1 ],
|
722
|
+
# alphanumeric against numeric
|
723
|
+
[ "0.0.2", "0.0.1a", 1 ],
|
724
|
+
[ "0.0.2a", "0.0.1", 1 ],
|
725
|
+
[ "0.0.1", "0.0.2a", -1 ],
|
726
|
+
[ "0.0.1a", "0.0.2", -1 ],
|
727
|
+
# length
|
728
|
+
[ "0.0.1aa", "0.0.1a", 1 ],
|
729
|
+
[ "0.0.1aa", "0.0.1aa", 0 ],
|
730
|
+
[ "0.0.1a", "0.0.1aa", -1 ],
|
731
|
+
].each do |x, y, result|
|
732
|
+
@rpmutils.rpmvercmp(x,y).should == result
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
it "should validate version compare logic for strange examples" do
|
737
|
+
[
|
738
|
+
[ "2,0,0", "1.0.0", 1 ],
|
739
|
+
[ "0.0.1", "0,0.1", 0 ],
|
740
|
+
[ "1.0.0", "2,0,0", -1 ],
|
741
|
+
[ "002.0.0", "001.0.0", 1 ],
|
742
|
+
[ "001..0.1", "001..0.0", 1 ],
|
743
|
+
[ "-001..1", "-001..0", 1 ],
|
744
|
+
[ "1.0.1", nil, 1 ],
|
745
|
+
[ nil, nil, 0 ],
|
746
|
+
[ nil, "1.0.1", -1 ],
|
747
|
+
[ "1.0.1", "", 1 ],
|
748
|
+
[ "", "", 0 ],
|
749
|
+
[ "", "1.0.1", -1 ]
|
750
|
+
].each do |x, y, result|
|
751
|
+
@rpmutils.rpmvercmp(x,y).should == result
|
752
|
+
end
|
753
|
+
end
|
754
|
+
|
755
|
+
it "tests isalnum good input" do
|
756
|
+
[ 'a', 'z', 'A', 'Z', '0', '9' ].each do |t|
|
757
|
+
@rpmutils.isalnum(t).should == true
|
758
|
+
end
|
759
|
+
end
|
760
|
+
|
761
|
+
it "tests isalnum bad input" do
|
762
|
+
[ '-', '.', '!', '^', ':', '_' ].each do |t|
|
763
|
+
@rpmutils.isalnum(t).should == false
|
764
|
+
end
|
765
|
+
end
|
766
|
+
|
767
|
+
it "tests isalpha good input" do
|
768
|
+
[ 'a', 'z', 'A', 'Z', ].each do |t|
|
769
|
+
@rpmutils.isalpha(t).should == true
|
770
|
+
end
|
771
|
+
end
|
772
|
+
|
773
|
+
it "tests isalpha bad input" do
|
774
|
+
[ '0', '9', '-', '.', '!', '^', ':', '_' ].each do |t|
|
775
|
+
@rpmutils.isalpha(t).should == false
|
776
|
+
end
|
777
|
+
end
|
778
|
+
|
779
|
+
it "tests isdigit good input" do
|
780
|
+
[ '0', '9', ].each do |t|
|
781
|
+
@rpmutils.isdigit(t).should == true
|
782
|
+
end
|
783
|
+
end
|
784
|
+
|
785
|
+
it "tests isdigit bad input" do
|
786
|
+
[ 'A', 'z', '-', '.', '!', '^', ':', '_' ].each do |t|
|
787
|
+
@rpmutils.isdigit(t).should == false
|
788
|
+
end
|
789
|
+
end
|
790
|
+
end
|
791
|
+
|
792
|
+
end
|
793
|
+
|
794
|
+
describe Chef::Provider::Package::Yum::RPMVersion do
|
795
|
+
describe "new - with parsing" do
|
796
|
+
before do
|
797
|
+
@rpmv = Chef::Provider::Package::Yum::RPMVersion.new("1:1.6.5-9.36.el5")
|
798
|
+
end
|
799
|
+
|
800
|
+
it "should expose evr (name-version-release) available" do
|
801
|
+
@rpmv.e.should == 1
|
802
|
+
@rpmv.v.should == "1.6.5"
|
803
|
+
@rpmv.r.should == "9.36.el5"
|
804
|
+
|
805
|
+
@rpmv.evr.should == "1:1.6.5-9.36.el5"
|
806
|
+
end
|
807
|
+
|
808
|
+
it "should output a version-release string" do
|
809
|
+
@rpmv.to_s.should == "1.6.5-9.36.el5"
|
810
|
+
end
|
811
|
+
end
|
812
|
+
|
813
|
+
describe "new - no parsing" do
|
814
|
+
before do
|
815
|
+
@rpmv = Chef::Provider::Package::Yum::RPMVersion.new("1", "1.6.5", "9.36.el5")
|
816
|
+
end
|
817
|
+
|
818
|
+
it "should expose evr (name-version-release) available" do
|
819
|
+
@rpmv.e.should == 1
|
820
|
+
@rpmv.v.should == "1.6.5"
|
821
|
+
@rpmv.r.should == "9.36.el5"
|
822
|
+
|
823
|
+
@rpmv.evr.should == "1:1.6.5-9.36.el5"
|
824
|
+
end
|
825
|
+
|
826
|
+
it "should output a version-release string" do
|
827
|
+
@rpmv.to_s.should == "1.6.5-9.36.el5"
|
828
|
+
end
|
829
|
+
end
|
830
|
+
|
831
|
+
it "should raise an error unless passed 1 or 3 args" do
|
832
|
+
lambda {
|
833
|
+
Chef::Provider::Package::Yum::RPMVersion.new()
|
834
|
+
}.should raise_error(ArgumentError)
|
835
|
+
lambda {
|
836
|
+
Chef::Provider::Package::Yum::RPMVersion.new("1:1.6.5-9.36.el5")
|
837
|
+
}.should_not raise_error
|
838
|
+
lambda {
|
839
|
+
Chef::Provider::Package::Yum::RPMVersion.new("1:1.6.5-9.36.el5", "extra")
|
840
|
+
}.should raise_error(ArgumentError)
|
841
|
+
lambda {
|
842
|
+
Chef::Provider::Package::Yum::RPMVersion.new("1", "1.6.5", "9.36.el5")
|
843
|
+
}.should_not raise_error
|
844
|
+
lambda {
|
845
|
+
Chef::Provider::Package::Yum::RPMVersion.new("1", "1.6.5", "9.36.el5", "extra")
|
846
|
+
}.should raise_error(ArgumentError)
|
847
|
+
end
|
848
|
+
|
849
|
+
# thanks version_class_spec.rb!
|
850
|
+
describe "compare" do
|
851
|
+
it "should sort based on complete epoch-version-release data" do
|
852
|
+
[
|
853
|
+
# smaller, larger
|
854
|
+
[ "0:1.6.5-9.36.el5",
|
855
|
+
"1:1.6.5-9.36.el5" ],
|
856
|
+
[ "0:2.3-15.el5",
|
857
|
+
"0:3.3-15.el5" ],
|
858
|
+
[ "0:alpha9.8-27.2",
|
859
|
+
"0:beta9.8-27.2" ],
|
860
|
+
[ "0:0.09-14jpp.3",
|
861
|
+
"0:0.09-15jpp.3" ],
|
862
|
+
[ "0:0.9.0-0.6.20110211.el5",
|
863
|
+
"0:0.9.0-0.6.20120211.el5" ],
|
864
|
+
[ "0:1.9.1-4.el5",
|
865
|
+
"0:1.9.1-5.el5" ],
|
866
|
+
[ "0:1.4.10-7.20090624svn.el5",
|
867
|
+
"0:1.4.10-7.20090625svn.el5" ],
|
868
|
+
[ "0:2.3.4-2.el5",
|
869
|
+
"0:2.3.4-2.el6" ]
|
870
|
+
].each do |smaller, larger|
|
871
|
+
sm = Chef::Provider::Package::Yum::RPMVersion.new(smaller)
|
872
|
+
lg = Chef::Provider::Package::Yum::RPMVersion.new(larger)
|
873
|
+
sm.should be < lg
|
874
|
+
lg.should be > sm
|
875
|
+
sm.should_not == lg
|
876
|
+
end
|
877
|
+
end
|
878
|
+
|
879
|
+
it "should sort based on partial epoch-version-release data" do
|
880
|
+
[
|
881
|
+
# smaller, larger
|
882
|
+
[ ":1.6.5-9.36.el5",
|
883
|
+
"1:1.6.5-9.36.el5" ],
|
884
|
+
[ "2.3-15.el5",
|
885
|
+
"3.3-15.el5" ],
|
886
|
+
[ "alpha9.8",
|
887
|
+
"beta9.8" ],
|
888
|
+
[ "14jpp",
|
889
|
+
"15jpp" ],
|
890
|
+
[ "0.9.0-0.6",
|
891
|
+
"0.9.0-0.7" ],
|
892
|
+
[ "0:1.9",
|
893
|
+
"3:1.9" ],
|
894
|
+
[ "2.3-2.el5",
|
895
|
+
"2.3-2.el6" ]
|
896
|
+
].each do |smaller, larger|
|
897
|
+
sm = Chef::Provider::Package::Yum::RPMVersion.new(smaller)
|
898
|
+
lg = Chef::Provider::Package::Yum::RPMVersion.new(larger)
|
899
|
+
sm.should be < lg
|
900
|
+
lg.should be > sm
|
901
|
+
sm.should_not == lg
|
902
|
+
end
|
903
|
+
end
|
904
|
+
|
905
|
+
it "should verify equality of complete epoch-version-release data" do
|
906
|
+
[
|
907
|
+
[ "0:1.6.5-9.36.el5",
|
908
|
+
"0:1.6.5-9.36.el5" ],
|
909
|
+
[ "0:2.3-15.el5",
|
910
|
+
"0:2.3-15.el5" ],
|
911
|
+
[ "0:alpha9.8-27.2",
|
912
|
+
"0:alpha9.8-27.2" ]
|
913
|
+
].each do |smaller, larger|
|
914
|
+
sm = Chef::Provider::Package::Yum::RPMVersion.new(smaller)
|
915
|
+
lg = Chef::Provider::Package::Yum::RPMVersion.new(larger)
|
916
|
+
sm.should be == lg
|
917
|
+
end
|
918
|
+
end
|
919
|
+
|
920
|
+
it "should verify equality of partial epoch-version-release data" do
|
921
|
+
[
|
922
|
+
[ ":1.6.5-9.36.el5",
|
923
|
+
"0:1.6.5-9.36.el5" ],
|
924
|
+
[ "2.3-15.el5",
|
925
|
+
"2.3-15.el5" ],
|
926
|
+
[ "alpha9.8-3",
|
927
|
+
"alpha9.8-3" ]
|
928
|
+
].each do |smaller, larger|
|
929
|
+
sm = Chef::Provider::Package::Yum::RPMVersion.new(smaller)
|
930
|
+
lg = Chef::Provider::Package::Yum::RPMVersion.new(larger)
|
931
|
+
sm.should be == lg
|
932
|
+
end
|
933
|
+
end
|
934
|
+
end
|
935
|
+
|
936
|
+
describe "partial compare" do
|
937
|
+
it "should compare based on partial epoch-version-release data" do
|
938
|
+
[
|
939
|
+
# smaller, larger
|
940
|
+
[ "0:1.1.1-1",
|
941
|
+
"1:" ],
|
942
|
+
[ "0:1.1.1-1",
|
943
|
+
"0:1.1.2" ],
|
944
|
+
[ "0:1.1.1-1",
|
945
|
+
"0:1.1.2-1" ],
|
946
|
+
[ "0:",
|
947
|
+
"1:1.1.1-1" ],
|
948
|
+
[ "0:1.1.1",
|
949
|
+
"0:1.1.2-1" ],
|
950
|
+
[ "0:1.1.1-1",
|
951
|
+
"0:1.1.2-1" ],
|
952
|
+
].each do |smaller, larger|
|
953
|
+
sm = Chef::Provider::Package::Yum::RPMVersion.new(smaller)
|
954
|
+
lg = Chef::Provider::Package::Yum::RPMVersion.new(larger)
|
955
|
+
sm.partial_compare(lg).should be == -1
|
956
|
+
lg.partial_compare(sm).should be == 1
|
957
|
+
sm.partial_compare(lg).should_not be == 0
|
958
|
+
end
|
959
|
+
end
|
960
|
+
|
961
|
+
it "should verify equality based on partial epoch-version-release data" do
|
962
|
+
[
|
963
|
+
[ "0:",
|
964
|
+
"0:1.1.1-1" ],
|
965
|
+
[ "0:1.1.1",
|
966
|
+
"0:1.1.1-1" ],
|
967
|
+
[ "0:1.1.1-1",
|
968
|
+
"0:1.1.1-1" ],
|
969
|
+
].each do |smaller, larger|
|
970
|
+
sm = Chef::Provider::Package::Yum::RPMVersion.new(smaller)
|
971
|
+
lg = Chef::Provider::Package::Yum::RPMVersion.new(larger)
|
972
|
+
sm.partial_compare(lg).should be == 0
|
973
|
+
end
|
974
|
+
end
|
975
|
+
end
|
976
|
+
|
977
|
+
end
|
978
|
+
|
979
|
+
describe Chef::Provider::Package::Yum::RPMPackage do
|
980
|
+
describe "new - with parsing" do
|
981
|
+
before do
|
982
|
+
@rpm = Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5", "x86_64", [])
|
983
|
+
end
|
984
|
+
|
985
|
+
it "should expose nevra (name-epoch-version-release-arch) available" do
|
986
|
+
@rpm.name.should == "testing"
|
987
|
+
@rpm.version.e.should == 1
|
988
|
+
@rpm.version.v.should == "1.6.5"
|
989
|
+
@rpm.version.r.should == "9.36.el5"
|
990
|
+
@rpm.arch.should == "x86_64"
|
991
|
+
|
992
|
+
@rpm.nevra.should == "testing-1:1.6.5-9.36.el5.x86_64"
|
993
|
+
@rpm.to_s.should == @rpm.nevra
|
994
|
+
end
|
995
|
+
|
996
|
+
it "should always have at least one provide, itself" do
|
997
|
+
@rpm.provides.size.should == 1
|
998
|
+
@rpm.provides[0].name == "testing"
|
999
|
+
@rpm.provides[0].version.evr == "1:1.6.5-9.36.el5"
|
1000
|
+
@rpm.provides[0].flag == :==
|
1001
|
+
end
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
describe "new - no parsing" do
|
1005
|
+
before do
|
1006
|
+
@rpm = Chef::Provider::Package::Yum::RPMPackage.new("testing", "1", "1.6.5", "9.36.el5", "x86_64", [])
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
it "should expose nevra (name-epoch-version-release-arch) available" do
|
1010
|
+
@rpm.name.should == "testing"
|
1011
|
+
@rpm.version.e.should == 1
|
1012
|
+
@rpm.version.v.should == "1.6.5"
|
1013
|
+
@rpm.version.r.should == "9.36.el5"
|
1014
|
+
@rpm.arch.should == "x86_64"
|
1015
|
+
|
1016
|
+
@rpm.nevra.should == "testing-1:1.6.5-9.36.el5.x86_64"
|
1017
|
+
@rpm.to_s.should == @rpm.nevra
|
1018
|
+
end
|
1019
|
+
|
1020
|
+
it "should always have at least one provide, itself" do
|
1021
|
+
@rpm.provides.size.should == 1
|
1022
|
+
@rpm.provides[0].name == "testing"
|
1023
|
+
@rpm.provides[0].version.evr == "1:1.6.5-9.36.el5"
|
1024
|
+
@rpm.provides[0].flag == :==
|
1025
|
+
end
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
it "should raise an error unless passed 4 or 6 args" do
|
1029
|
+
lambda {
|
1030
|
+
Chef::Provider::Package::Yum::RPMPackage.new()
|
1031
|
+
}.should raise_error(ArgumentError)
|
1032
|
+
lambda {
|
1033
|
+
Chef::Provider::Package::Yum::RPMPackage.new("testing")
|
1034
|
+
}.should raise_error(ArgumentError)
|
1035
|
+
lambda {
|
1036
|
+
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5")
|
1037
|
+
}.should raise_error(ArgumentError)
|
1038
|
+
lambda {
|
1039
|
+
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5", "x86_64")
|
1040
|
+
}.should raise_error(ArgumentError)
|
1041
|
+
lambda {
|
1042
|
+
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1:1.6.5-9.36.el5", "x86_64", [])
|
1043
|
+
}.should_not raise_error
|
1044
|
+
lambda {
|
1045
|
+
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1", "1.6.5", "9.36.el5", "x86_64")
|
1046
|
+
}.should raise_error(ArgumentError)
|
1047
|
+
lambda {
|
1048
|
+
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1", "1.6.5", "9.36.el5", "x86_64", [])
|
1049
|
+
}.should_not raise_error
|
1050
|
+
lambda {
|
1051
|
+
Chef::Provider::Package::Yum::RPMPackage.new("testing", "1", "1.6.5", "9.36.el5", "x86_64", [], "extra")
|
1052
|
+
}.should raise_error(ArgumentError)
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
describe "<=>" do
|
1056
|
+
it "should sort alphabetically based on package name" do
|
1057
|
+
[
|
1058
|
+
[ "a-test",
|
1059
|
+
"b-test" ],
|
1060
|
+
[ "B-test",
|
1061
|
+
"a-test" ],
|
1062
|
+
[ "A-test",
|
1063
|
+
"B-test" ],
|
1064
|
+
[ "Aa-test",
|
1065
|
+
"aA-test" ],
|
1066
|
+
[ "1test",
|
1067
|
+
"2test" ],
|
1068
|
+
].each do |smaller, larger|
|
1069
|
+
sm = Chef::Provider::Package::Yum::RPMPackage.new(smaller, "0:0.0.1-1", "x86_64", [])
|
1070
|
+
lg = Chef::Provider::Package::Yum::RPMPackage.new(larger, "0:0.0.1-1", "x86_64", [])
|
1071
|
+
sm.should be < lg
|
1072
|
+
lg.should be > sm
|
1073
|
+
sm.should_not == lg
|
1074
|
+
end
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
it "should sort alphabetically based on package arch" do
|
1078
|
+
[
|
1079
|
+
[ "i386",
|
1080
|
+
"x86_64" ],
|
1081
|
+
[ "i386",
|
1082
|
+
"noarch" ],
|
1083
|
+
[ "noarch",
|
1084
|
+
"x86_64" ],
|
1085
|
+
].each do |smaller, larger|
|
1086
|
+
sm = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "0:0.0.1-1", smaller, [])
|
1087
|
+
lg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "0:0.0.1-1", larger, [])
|
1088
|
+
sm.should be < lg
|
1089
|
+
lg.should be > sm
|
1090
|
+
sm.should_not == lg
|
1091
|
+
end
|
1092
|
+
end
|
1093
|
+
end
|
1094
|
+
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
describe Chef::Provider::Package::Yum::RPMDbPackage do
|
1098
|
+
before(:each) do
|
1099
|
+
# name, version, arch, installed, available, repoid
|
1100
|
+
@rpm_x = Chef::Provider::Package::Yum::RPMDbPackage.new("test-package-b", "0:1.6.5-9.36.el5", "noarch", [], false, true, "base")
|
1101
|
+
@rpm_y = Chef::Provider::Package::Yum::RPMDbPackage.new("test-package-b", "0:1.6.5-9.36.el5", "noarch", [], true, true, "extras")
|
1102
|
+
@rpm_z = Chef::Provider::Package::Yum::RPMDbPackage.new("test-package-b", "0:1.6.5-9.36.el5", "noarch", [], true, false, "other")
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
describe "initialize" do
|
1106
|
+
it "should return a Chef::Provider::Package::Yum::RPMDbPackage object" do
|
1107
|
+
@rpm_x.should be_kind_of(Chef::Provider::Package::Yum::RPMDbPackage)
|
1108
|
+
end
|
1109
|
+
end
|
1110
|
+
|
1111
|
+
describe "available" do
|
1112
|
+
it "should return true" do
|
1113
|
+
@rpm_x.available.should be == true
|
1114
|
+
@rpm_y.available.should be == true
|
1115
|
+
@rpm_z.available.should be == false
|
1116
|
+
end
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
describe "installed" do
|
1120
|
+
it "should return true" do
|
1121
|
+
@rpm_x.installed.should be == false
|
1122
|
+
@rpm_y.installed.should be == true
|
1123
|
+
@rpm_z.installed.should be == true
|
1124
|
+
end
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
describe "repoid" do
|
1128
|
+
it "should return the source repository repoid" do
|
1129
|
+
@rpm_x.repoid.should be == "base"
|
1130
|
+
@rpm_y.repoid.should be == "extras"
|
1131
|
+
@rpm_z.repoid.should be == "other"
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
end
|
1135
|
+
|
1136
|
+
describe Chef::Provider::Package::Yum::RPMDependency do
|
1137
|
+
describe "new - with parsing" do
|
1138
|
+
before do
|
1139
|
+
@rpmdep = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :==)
|
1140
|
+
end
|
1141
|
+
|
1142
|
+
it "should expose name, version, flag available" do
|
1143
|
+
@rpmdep.name.should == "testing"
|
1144
|
+
@rpmdep.version.e.should == 1
|
1145
|
+
@rpmdep.version.v.should == "1.6.5"
|
1146
|
+
@rpmdep.version.r.should == "9.36.el5"
|
1147
|
+
@rpmdep.flag.should == :==
|
1148
|
+
end
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
describe "new - no parsing" do
|
1152
|
+
before do
|
1153
|
+
@rpmdep = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1", "1.6.5", "9.36.el5", :==)
|
1154
|
+
end
|
1155
|
+
|
1156
|
+
it "should expose name, version, flag available" do
|
1157
|
+
@rpmdep.name.should == "testing"
|
1158
|
+
@rpmdep.version.e.should == 1
|
1159
|
+
@rpmdep.version.v.should == "1.6.5"
|
1160
|
+
@rpmdep.version.r.should == "9.36.el5"
|
1161
|
+
@rpmdep.flag.should == :==
|
1162
|
+
end
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
it "should raise an error unless passed 3 or 5 args" do
|
1166
|
+
lambda {
|
1167
|
+
Chef::Provider::Package::Yum::RPMDependency.new()
|
1168
|
+
}.should raise_error(ArgumentError)
|
1169
|
+
lambda {
|
1170
|
+
Chef::Provider::Package::Yum::RPMDependency.new("testing")
|
1171
|
+
}.should raise_error(ArgumentError)
|
1172
|
+
lambda {
|
1173
|
+
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5")
|
1174
|
+
}.should raise_error(ArgumentError)
|
1175
|
+
lambda {
|
1176
|
+
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :==)
|
1177
|
+
}.should_not raise_error
|
1178
|
+
lambda {
|
1179
|
+
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :==, "extra")
|
1180
|
+
}.should raise_error(ArgumentError)
|
1181
|
+
lambda {
|
1182
|
+
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1", "1.6.5", "9.36.el5", :==)
|
1183
|
+
}.should_not raise_error
|
1184
|
+
lambda {
|
1185
|
+
Chef::Provider::Package::Yum::RPMDependency.new("testing", "1", "1.6.5", "9.36.el5", :==, "extra")
|
1186
|
+
}.should raise_error(ArgumentError)
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
describe "parse" do
|
1190
|
+
it "should parse a name, flag, version string into a valid RPMDependency object" do
|
1191
|
+
@rpmdep = Chef::Provider::Package::Yum::RPMDependency.parse("testing >= 1:1.6.5-9.36.el5")
|
1192
|
+
|
1193
|
+
@rpmdep.name.should == "testing"
|
1194
|
+
@rpmdep.version.e.should == 1
|
1195
|
+
@rpmdep.version.v.should == "1.6.5"
|
1196
|
+
@rpmdep.version.r.should == "9.36.el5"
|
1197
|
+
@rpmdep.flag.should == :>=
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
it "should parse a name into a valid RPMDependency object" do
|
1201
|
+
@rpmdep = Chef::Provider::Package::Yum::RPMDependency.parse("testing")
|
1202
|
+
|
1203
|
+
@rpmdep.name.should == "testing"
|
1204
|
+
@rpmdep.version.e.should == nil
|
1205
|
+
@rpmdep.version.v.should == nil
|
1206
|
+
@rpmdep.version.r.should == nil
|
1207
|
+
@rpmdep.flag.should == :==
|
1208
|
+
end
|
1209
|
+
|
1210
|
+
it "should parse an invalid string into the name of a RPMDependency object" do
|
1211
|
+
@rpmdep = Chef::Provider::Package::Yum::RPMDependency.parse("testing blah >")
|
1212
|
+
|
1213
|
+
@rpmdep.name.should == "testing blah >"
|
1214
|
+
@rpmdep.version.e.should == nil
|
1215
|
+
@rpmdep.version.v.should == nil
|
1216
|
+
@rpmdep.version.r.should == nil
|
1217
|
+
@rpmdep.flag.should == :==
|
1218
|
+
end
|
1219
|
+
|
1220
|
+
it "should parse various valid flags" do
|
1221
|
+
[
|
1222
|
+
[ ">", :> ],
|
1223
|
+
[ ">=", :>= ],
|
1224
|
+
[ "=", :== ],
|
1225
|
+
[ "==", :== ],
|
1226
|
+
[ "<=", :<= ],
|
1227
|
+
[ "<", :< ]
|
1228
|
+
].each do |before, after|
|
1229
|
+
@rpmdep = Chef::Provider::Package::Yum::RPMDependency.parse("testing #{before} 1:1.1-1")
|
1230
|
+
@rpmdep.flag.should == after
|
1231
|
+
end
|
1232
|
+
end
|
1233
|
+
|
1234
|
+
it "should parse various invalid flags and treat them as names" do
|
1235
|
+
[
|
1236
|
+
[ "<>", :== ],
|
1237
|
+
[ "!=", :== ],
|
1238
|
+
[ ">>", :== ],
|
1239
|
+
[ "<<", :== ],
|
1240
|
+
[ "!", :== ],
|
1241
|
+
[ "~", :== ]
|
1242
|
+
].each do |before, after|
|
1243
|
+
@rpmdep = Chef::Provider::Package::Yum::RPMDependency.parse("testing #{before} 1:1.1-1")
|
1244
|
+
@rpmdep.name.should == "testing #{before} 1:1.1-1"
|
1245
|
+
@rpmdep.flag.should == after
|
1246
|
+
end
|
1247
|
+
end
|
1248
|
+
end
|
1249
|
+
|
1250
|
+
describe "satisfy?" do
|
1251
|
+
it "should raise an error unless a RPMDependency is passed" do
|
1252
|
+
@rpmprovide = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :==)
|
1253
|
+
@rpmrequire = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :>=)
|
1254
|
+
lambda {
|
1255
|
+
@rpmprovide.satisfy?("hi")
|
1256
|
+
}.should raise_error(ArgumentError)
|
1257
|
+
lambda {
|
1258
|
+
@rpmprovide.satisfy?(@rpmrequire)
|
1259
|
+
}.should_not raise_error
|
1260
|
+
end
|
1261
|
+
|
1262
|
+
it "should validate dependency satisfaction logic for standard examples" do
|
1263
|
+
[
|
1264
|
+
# names
|
1265
|
+
[ "test", "test", true ],
|
1266
|
+
[ "test", "foo", false ],
|
1267
|
+
# full: epoch:version-relese
|
1268
|
+
[ "testing = 1:1.1-1", "testing > 1:1.1-0", true ],
|
1269
|
+
[ "testing = 1:1.1-1", "testing >= 1:1.1-0", true ],
|
1270
|
+
[ "testing = 1:1.1-1", "testing >= 1:1.1-1", true ],
|
1271
|
+
[ "testing = 1:1.1-1", "testing = 1:1.1-1", true ],
|
1272
|
+
[ "testing = 1:1.1-1", "testing == 1:1.1-1", true ],
|
1273
|
+
[ "testing = 1:1.1-1", "testing <= 1:1.1-1", true ],
|
1274
|
+
[ "testing = 1:1.1-1", "testing <= 1:1.1-0", false ],
|
1275
|
+
[ "testing = 1:1.1-1", "testing < 1:1.1-0", false ],
|
1276
|
+
# partial: epoch:version
|
1277
|
+
[ "testing = 1:1.1", "testing > 1:1.0", true ],
|
1278
|
+
[ "testing = 1:1.1", "testing >= 1:1.0", true ],
|
1279
|
+
[ "testing = 1:1.1", "testing >= 1:1.1", true ],
|
1280
|
+
[ "testing = 1:1.1", "testing = 1:1.1", true ],
|
1281
|
+
[ "testing = 1:1.1", "testing == 1:1.1", true ],
|
1282
|
+
[ "testing = 1:1.1", "testing <= 1:1.1", true ],
|
1283
|
+
[ "testing = 1:1.1", "testing <= 1:1.0", false ],
|
1284
|
+
[ "testing = 1:1.1", "testing < 1:1.0", false ],
|
1285
|
+
# partial: epoch
|
1286
|
+
[ "testing = 1:", "testing > 0:", true ],
|
1287
|
+
[ "testing = 1:", "testing >= 0:", true ],
|
1288
|
+
[ "testing = 1:", "testing >= 1:", true ],
|
1289
|
+
[ "testing = 1:", "testing = 1:", true ],
|
1290
|
+
[ "testing = 1:", "testing == 1:", true ],
|
1291
|
+
[ "testing = 1:", "testing <= 1:", true ],
|
1292
|
+
[ "testing = 1:", "testing <= 0:", false ],
|
1293
|
+
[ "testing = 1:", "testing < 0:", false ],
|
1294
|
+
# mix and match!
|
1295
|
+
[ "testing = 1:1.1-1", "testing == 1:1.1", true ],
|
1296
|
+
[ "testing = 1:1.1-1", "testing == 1:", true ],
|
1297
|
+
].each do |prov, req, result|
|
1298
|
+
@rpmprovide = Chef::Provider::Package::Yum::RPMDependency.parse(prov)
|
1299
|
+
@rpmrequire = Chef::Provider::Package::Yum::RPMDependency.parse(req)
|
1300
|
+
|
1301
|
+
@rpmprovide.satisfy?(@rpmrequire).should == result
|
1302
|
+
@rpmrequire.satisfy?(@rpmprovide).should == result
|
1303
|
+
end
|
1304
|
+
end
|
1305
|
+
end
|
1306
|
+
|
1307
|
+
end
|
1308
|
+
|
1309
|
+
# thanks resource_collection_spec.rb!
|
1310
|
+
describe Chef::Provider::Package::Yum::RPMDb do
|
1311
|
+
before(:each) do
|
1312
|
+
@rpmdb = Chef::Provider::Package::Yum::RPMDb.new
|
1313
|
+
# name, version, arch, installed, available
|
1314
|
+
deps_v = [
|
1315
|
+
Chef::Provider::Package::Yum::RPMDependency.parse("libz.so.1()(64bit)"),
|
1316
|
+
Chef::Provider::Package::Yum::RPMDependency.parse("test-package-a = 0:1.6.5-9.36.el5")
|
1317
|
+
]
|
1318
|
+
deps_z = [
|
1319
|
+
Chef::Provider::Package::Yum::RPMDependency.parse("libz.so.1()(64bit)"),
|
1320
|
+
Chef::Provider::Package::Yum::RPMDependency.parse("config(test) = 0:1.6.5-9.36.el5"),
|
1321
|
+
Chef::Provider::Package::Yum::RPMDependency.parse("test-package-c = 0:1.6.5-9.36.el5")
|
1322
|
+
]
|
1323
|
+
@rpm_v = Chef::Provider::Package::Yum::RPMDbPackage.new("test-package-a", "0:1.6.5-9.36.el5", "i386", deps_v, true, false, "base")
|
1324
|
+
@rpm_w = Chef::Provider::Package::Yum::RPMDbPackage.new("test-package-b", "0:1.6.5-9.36.el5", "i386", [], true, true, "extras")
|
1325
|
+
@rpm_x = Chef::Provider::Package::Yum::RPMDbPackage.new("test-package-b", "0:1.6.5-9.36.el5", "x86_64", [], false, true, "extras")
|
1326
|
+
@rpm_y = Chef::Provider::Package::Yum::RPMDbPackage.new("test-package-b", "1:1.6.5-9.36.el5", "x86_64", [], true, true, "extras")
|
1327
|
+
@rpm_z = Chef::Provider::Package::Yum::RPMDbPackage.new("test-package-c", "0:1.6.5-9.36.el5", "noarch", deps_z, true, true, "base")
|
1328
|
+
@rpm_z_mirror = Chef::Provider::Package::Yum::RPMDbPackage.new("test-package-c", "0:1.6.5-9.36.el5", "noarch", deps_z, true, true, "base")
|
1329
|
+
end
|
1330
|
+
|
1331
|
+
describe "initialize" do
|
1332
|
+
it "should return a Chef::Provider::Package::Yum::RPMDb object" do
|
1333
|
+
@rpmdb.should be_kind_of(Chef::Provider::Package::Yum::RPMDb)
|
1334
|
+
end
|
1335
|
+
end
|
1336
|
+
|
1337
|
+
describe "push" do
|
1338
|
+
it "should accept an RPMDbPackage object through pushing" do
|
1339
|
+
lambda { @rpmdb.push(@rpm_w) }.should_not raise_error
|
1340
|
+
end
|
1341
|
+
|
1342
|
+
it "should accept multiple RPMDbPackage object through pushing" do
|
1343
|
+
lambda { @rpmdb.push(@rpm_w, @rpm_x, @rpm_y, @rpm_z) }.should_not raise_error
|
1344
|
+
end
|
1345
|
+
|
1346
|
+
it "should only accept an RPMDbPackage object" do
|
1347
|
+
lambda { @rpmdb.push("string") }.should raise_error
|
1348
|
+
end
|
1349
|
+
|
1350
|
+
it "should add the package to the package db" do
|
1351
|
+
@rpmdb.push(@rpm_w)
|
1352
|
+
@rpmdb["test-package-b"].should_not be == nil
|
1353
|
+
end
|
1354
|
+
|
1355
|
+
it "should add conditionally add the package to the available list" do
|
1356
|
+
@rpmdb.available_size.should be == 0
|
1357
|
+
@rpmdb.push(@rpm_v, @rpm_w)
|
1358
|
+
@rpmdb.available_size.should be == 1
|
1359
|
+
end
|
1360
|
+
|
1361
|
+
it "should add conditionally add the package to the installed list" do
|
1362
|
+
@rpmdb.installed_size.should be == 0
|
1363
|
+
@rpmdb.push(@rpm_w, @rpm_x)
|
1364
|
+
@rpmdb.installed_size.should be == 1
|
1365
|
+
end
|
1366
|
+
|
1367
|
+
it "should have a total of 2 packages in the RPMDb" do
|
1368
|
+
@rpmdb.size.should be == 0
|
1369
|
+
@rpmdb.push(@rpm_w, @rpm_x, @rpm_y, @rpm_z)
|
1370
|
+
@rpmdb.size.should be == 2
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
it "should keep the Array unique when a duplicate is pushed" do
|
1374
|
+
@rpmdb.push(@rpm_z, @rpm_z_mirror)
|
1375
|
+
@rpmdb["test-package-c"].size.should be == 1
|
1376
|
+
end
|
1377
|
+
|
1378
|
+
it "should register the package provides in the provides index" do
|
1379
|
+
@rpmdb.push(@rpm_v, @rpm_w, @rpm_z)
|
1380
|
+
@rpmdb.lookup_provides("test-package-a")[0].should be == @rpm_v
|
1381
|
+
@rpmdb.lookup_provides("config(test)")[0].should be == @rpm_z
|
1382
|
+
@rpmdb.lookup_provides("libz.so.1()(64bit)")[0].should be == @rpm_v
|
1383
|
+
@rpmdb.lookup_provides("libz.so.1()(64bit)")[1].should be == @rpm_z
|
1384
|
+
end
|
1385
|
+
end
|
1386
|
+
|
1387
|
+
describe "<<" do
|
1388
|
+
it "should accept an RPMPackage object through the << operator" do
|
1389
|
+
lambda { @rpmdb << @rpm_w }.should_not raise_error
|
1390
|
+
end
|
1391
|
+
end
|
1392
|
+
|
1393
|
+
describe "lookup" do
|
1394
|
+
it "should return an Array of RPMPackage objects by index" do
|
1395
|
+
@rpmdb << @rpm_w
|
1396
|
+
@rpmdb.lookup("test-package-b").should be_kind_of(Array)
|
1397
|
+
end
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
describe "[]" do
|
1401
|
+
it "should return an Array of RPMPackage objects though the [index] operator" do
|
1402
|
+
@rpmdb << @rpm_w
|
1403
|
+
@rpmdb["test-package-b"].should be_kind_of(Array)
|
1404
|
+
end
|
1405
|
+
|
1406
|
+
it "should return an Array of 3 RPMPackage objects" do
|
1407
|
+
@rpmdb.push(@rpm_w, @rpm_x, @rpm_y, @rpm_z)
|
1408
|
+
@rpmdb["test-package-b"].size.should be == 3
|
1409
|
+
end
|
1410
|
+
|
1411
|
+
it "should return an Array of RPMPackage objects sorted from newest to oldest" do
|
1412
|
+
@rpmdb.push(@rpm_w, @rpm_x, @rpm_y, @rpm_z)
|
1413
|
+
@rpmdb["test-package-b"][0].should be == @rpm_y
|
1414
|
+
@rpmdb["test-package-b"][1].should be == @rpm_x
|
1415
|
+
@rpmdb["test-package-b"][2].should be == @rpm_w
|
1416
|
+
end
|
1417
|
+
end
|
1418
|
+
|
1419
|
+
describe "lookup_provides" do
|
1420
|
+
it "should return an Array of RPMPackage objects by index" do
|
1421
|
+
@rpmdb << @rpm_z
|
1422
|
+
x = @rpmdb.lookup_provides("config(test)")
|
1423
|
+
x.should be_kind_of(Array)
|
1424
|
+
x[0].should be == @rpm_z
|
1425
|
+
end
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
describe "clear" do
|
1429
|
+
it "should clear the RPMDb" do
|
1430
|
+
@rpmdb.should_receive(:clear_available).once
|
1431
|
+
@rpmdb.should_receive(:clear_installed).once
|
1432
|
+
@rpmdb.push(@rpm_w, @rpm_x, @rpm_y, @rpm_z)
|
1433
|
+
@rpmdb.size.should_not be == 0
|
1434
|
+
@rpmdb.lookup_provides("config(test)").should be_kind_of(Array)
|
1435
|
+
@rpmdb.clear
|
1436
|
+
@rpmdb.lookup_provides("config(test)").should be == nil
|
1437
|
+
@rpmdb.size.should be == 0
|
1438
|
+
end
|
1439
|
+
end
|
1440
|
+
|
1441
|
+
describe "clear_available" do
|
1442
|
+
it "should clear the available list" do
|
1443
|
+
@rpmdb.push(@rpm_w, @rpm_x, @rpm_y, @rpm_z)
|
1444
|
+
@rpmdb.available_size.should_not be == 0
|
1445
|
+
@rpmdb.clear_available
|
1446
|
+
@rpmdb.available_size.should be == 0
|
1447
|
+
end
|
1448
|
+
end
|
1449
|
+
|
1450
|
+
describe "available?" do
|
1451
|
+
it "should return true if a package is available" do
|
1452
|
+
@rpmdb.available?(@rpm_w).should be == false
|
1453
|
+
@rpmdb.push(@rpm_v, @rpm_w)
|
1454
|
+
@rpmdb.available?(@rpm_v).should be == false
|
1455
|
+
@rpmdb.available?(@rpm_w).should be == true
|
1456
|
+
end
|
1457
|
+
end
|
1458
|
+
|
1459
|
+
describe "clear_installed" do
|
1460
|
+
it "should clear the installed list" do
|
1461
|
+
@rpmdb.push(@rpm_w, @rpm_x, @rpm_y, @rpm_z)
|
1462
|
+
@rpmdb.installed_size.should_not be == 0
|
1463
|
+
@rpmdb.clear_installed
|
1464
|
+
@rpmdb.installed_size.should be == 0
|
1465
|
+
end
|
1466
|
+
end
|
1467
|
+
|
1468
|
+
describe "installed?" do
|
1469
|
+
it "should return true if a package is installed" do
|
1470
|
+
@rpmdb.installed?(@rpm_w).should be == false
|
1471
|
+
@rpmdb.push(@rpm_w, @rpm_x)
|
1472
|
+
@rpmdb.installed?(@rpm_w).should be == true
|
1473
|
+
@rpmdb.installed?(@rpm_x).should be == false
|
1474
|
+
end
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
describe "whatprovides" do
|
1478
|
+
it "should raise an error unless a RPMDependency is passed" do
|
1479
|
+
@rpmprovide = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :==)
|
1480
|
+
@rpmrequire = Chef::Provider::Package::Yum::RPMDependency.new("testing", "1:1.6.5-9.36.el5", :>=)
|
1481
|
+
lambda {
|
1482
|
+
@rpmdb.whatprovides("hi")
|
1483
|
+
}.should raise_error(ArgumentError)
|
1484
|
+
lambda {
|
1485
|
+
@rpmdb.whatprovides(@rpmrequire)
|
1486
|
+
}.should_not raise_error
|
1487
|
+
end
|
1488
|
+
|
1489
|
+
it "should return an Array of packages statisfying a RPMDependency" do
|
1490
|
+
@rpmdb.push(@rpm_v, @rpm_w, @rpm_z)
|
1491
|
+
|
1492
|
+
@rpmrequire = Chef::Provider::Package::Yum::RPMDependency.parse("test-package-a >= 1.6.5")
|
1493
|
+
x = @rpmdb.whatprovides(@rpmrequire)
|
1494
|
+
x.should be_kind_of(Array)
|
1495
|
+
x[0].should be == @rpm_v
|
1496
|
+
|
1497
|
+
@rpmrequire = Chef::Provider::Package::Yum::RPMDependency.parse("libz.so.1()(64bit)")
|
1498
|
+
x = @rpmdb.whatprovides(@rpmrequire)
|
1499
|
+
x.should be_kind_of(Array)
|
1500
|
+
x[0].should be == @rpm_v
|
1501
|
+
x[1].should be == @rpm_z
|
1502
|
+
end
|
1503
|
+
end
|
1504
|
+
|
1505
|
+
end
|
1506
|
+
|
1507
|
+
describe Chef::Provider::Package::Yum::YumCache do
|
1508
|
+
# allow for the reset of a Singleton
|
1509
|
+
# thanks to Ian White (http://blog.ardes.com/2006/12/11/testing-singletons-with-ruby)
|
1510
|
+
class << Chef::Provider::Package::Yum::YumCache
|
1511
|
+
def reset_instance
|
1512
|
+
Singleton.send :__init__, self
|
1513
|
+
self
|
1514
|
+
end
|
1515
|
+
end
|
1516
|
+
|
1517
|
+
before(:each) do
|
1518
|
+
yum_dump_good_output = <<EOF
|
1519
|
+
[option installonlypkgs] kernel kernel-bigmem kernel-enterprise
|
1520
|
+
erlang-mochiweb 0 1.4.1 5.el5 x86_64 ['erlang-mochiweb = 1.4.1-5.el5', 'mochiweb = 1.4.1-5.el5'] i installed
|
1521
|
+
zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
|
1522
|
+
zisofs-tools 0 1.0.6 3.2.2 x86_64 [] a extras
|
1523
|
+
zlib 0 1.2.3 3 x86_64 ['zlib = 1.2.3-3', 'libz.so.1()(64bit)'] r base
|
1524
|
+
zlib 0 1.2.3 3 i386 ['zlib = 1.2.3-3', 'libz.so.1'] r base
|
1525
|
+
zlib-devel 0 1.2.3 3 i386 [] a extras
|
1526
|
+
zlib-devel 0 1.2.3 3 x86_64 ['zlib-devel = 1.2.3-3'] r base
|
1527
|
+
znc 0 0.098 1.el5 x86_64 [] a base
|
1528
|
+
znc-devel 0 0.098 1.el5 i386 [] a extras
|
1529
|
+
znc-devel 0 0.098 1.el5 x86_64 [] a base
|
1530
|
+
znc-extra 0 0.098 1.el5 x86_64 [] a base
|
1531
|
+
znc-modtcl 0 0.098 1.el5 x86_64 [] a base
|
1532
|
+
znc-test.beta1 0 0.098 1.el5 x86_64 [] a extras
|
1533
|
+
znc-test.test.beta1 0 0.098 1.el5 x86_64 [] a base
|
1534
|
+
EOF
|
1535
|
+
|
1536
|
+
yum_dump_bad_output_separators = <<EOF
|
1537
|
+
zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
|
1538
|
+
zlib 0 1.2.3 3 x86_64 ['zlib = 1.2.3-3', 'libz.so.1()(64bit)'] i base bad
|
1539
|
+
zlib-devel 0 1.2.3 3 i386 [] a extras
|
1540
|
+
bad zlib-devel 0 1.2.3 3 x86_64 ['zlib-devel = 1.2.3-3'] i installed
|
1541
|
+
znc-modtcl 0 0.098 1.el5 x86_64 [] a base bad
|
1542
|
+
EOF
|
1543
|
+
|
1544
|
+
yum_dump_bad_output_type = <<EOF
|
1545
|
+
zip 0 2.31 2.el5 x86_64 ['zip = 2.31-2.el5'] r base
|
1546
|
+
zlib 0 1.2.3 3 x86_64 ['zlib = 1.2.3-3', 'libz.so.1()(64bit)'] c base
|
1547
|
+
zlib-devel 0 1.2.3 3 i386 [] a extras
|
1548
|
+
zlib-devel 0 1.2.3 3 x86_64 ['zlib-devel = 1.2.3-3'] bad installed
|
1549
|
+
znc-modtcl 0 0.098 1.el5 x86_64 [] a base
|
1550
|
+
EOF
|
1551
|
+
|
1552
|
+
yum_dump_error = <<EOF
|
1553
|
+
yum-dump Config Error: File contains no section headers.
|
1554
|
+
file: file://///etc/yum.repos.d/CentOS-Base.repo, line: 12
|
1555
|
+
'qeqwewe\n'
|
1556
|
+
EOF
|
1557
|
+
|
1558
|
+
@status = mock("Status", :exitstatus => 0)
|
1559
|
+
@status_bad = mock("Status", :exitstatus => 1)
|
1560
|
+
@stdin = mock("STDIN", :nil_object => true)
|
1561
|
+
@stdout = mock("STDOUT", :nil_object => true)
|
1562
|
+
@stdout_good = yum_dump_good_output.split("\n")
|
1563
|
+
@stdout_bad_type = yum_dump_bad_output_type.split("\n")
|
1564
|
+
@stdout_bad_separators = yum_dump_bad_output_separators.split("\n")
|
1565
|
+
@stderr = mock("STDERR", :nil_object => true)
|
1566
|
+
@stderr.stub!(:readlines).and_return(yum_dump_error.split("\n"))
|
1567
|
+
@pid = mock("PID", :nil_object => true)
|
1568
|
+
|
1569
|
+
# new singleton each time
|
1570
|
+
Chef::Provider::Package::Yum::YumCache.reset_instance
|
1571
|
+
@yc = Chef::Provider::Package::Yum::YumCache.instance
|
1572
|
+
# load valid data
|
1573
|
+
@yc.stub!(:popen4).and_yield(@pid, @stdin, @stdout_good, @stderr).and_return(@status)
|
1574
|
+
end
|
1575
|
+
|
1576
|
+
describe "initialize" do
|
1577
|
+
it "should return a Chef::Provider::Package::Yum::YumCache object" do
|
1578
|
+
@yc.should be_kind_of(Chef::Provider::Package::Yum::YumCache)
|
1579
|
+
end
|
1580
|
+
|
1581
|
+
it "should register reload for start of Chef::Client runs" do
|
1582
|
+
Chef::Provider::Package::Yum::YumCache.reset_instance
|
1583
|
+
Chef::Client.should_receive(:when_run_starts) do |&b|
|
1584
|
+
b.should_not be_nil
|
1585
|
+
end
|
1586
|
+
@yc = Chef::Provider::Package::Yum::YumCache.instance
|
1587
|
+
end
|
1588
|
+
end
|
1589
|
+
|
1590
|
+
describe "refresh" do
|
1591
|
+
it "should implicitly call yum-dump.py only once by default after being instantiated" do
|
1592
|
+
@yc.should_receive(:popen4).once
|
1593
|
+
@yc.installed_version("zlib")
|
1594
|
+
@yc.reset
|
1595
|
+
@yc.installed_version("zlib")
|
1596
|
+
end
|
1597
|
+
|
1598
|
+
it "should run yum-dump.py using the system python when next_refresh is for :all" do
|
1599
|
+
@yc.reload
|
1600
|
+
@yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides$}, :waitlast=>true)
|
1601
|
+
@yc.refresh
|
1602
|
+
end
|
1603
|
+
|
1604
|
+
it "should run yum-dump.py with the installed flag when next_refresh is for :installed" do
|
1605
|
+
@yc.reload_installed
|
1606
|
+
@yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --installed$}, :waitlast=>true)
|
1607
|
+
@yc.refresh
|
1608
|
+
end
|
1609
|
+
|
1610
|
+
it "should run yum-dump.py with the all-provides flag when next_refresh is for :provides" do
|
1611
|
+
@yc.reload_provides
|
1612
|
+
@yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --options --all-provides$}, :waitlast=>true)
|
1613
|
+
@yc.refresh
|
1614
|
+
end
|
1615
|
+
|
1616
|
+
it "should warn about invalid data with too many separators" do
|
1617
|
+
@yc.stub!(:popen4).and_yield(@pid, @stdin, @stdout_bad_separators, @stderr).and_return(@status)
|
1618
|
+
Chef::Log.should_receive(:warn).exactly(3).times.with(%r{Problem parsing})
|
1619
|
+
@yc.refresh
|
1620
|
+
end
|
1621
|
+
|
1622
|
+
it "should warn about invalid data with an incorrect type" do
|
1623
|
+
@yc.stub!(:popen4).and_yield(@pid, @stdin, @stdout_bad_type, @stderr).and_return(@status)
|
1624
|
+
Chef::Log.should_receive(:warn).exactly(2).times.with(%r{Problem parsing})
|
1625
|
+
@yc.refresh
|
1626
|
+
end
|
1627
|
+
|
1628
|
+
it "should warn about no output from yum-dump.py" do
|
1629
|
+
@yc.stub!(:popen4).and_yield(@pid, @stdin, [], @stderr).and_return(@status)
|
1630
|
+
Chef::Log.should_receive(:warn).exactly(1).times.with(%r{no output from yum-dump.py})
|
1631
|
+
@yc.refresh
|
1632
|
+
end
|
1633
|
+
|
1634
|
+
it "should raise exception yum-dump.py exits with a non zero status" do
|
1635
|
+
@yc.stub!(:popen4).and_yield(@pid, @stdin, [], @stderr).and_return(@status_bad)
|
1636
|
+
lambda { @yc.refresh}.should raise_error(Chef::Exceptions::Package, %r{CentOS-Base.repo, line: 12})
|
1637
|
+
end
|
1638
|
+
|
1639
|
+
it "should parse type 'i' into an installed state for a package" do
|
1640
|
+
@yc.available_version("erlang-mochiweb").should be == nil
|
1641
|
+
@yc.installed_version("erlang-mochiweb").should_not be == nil
|
1642
|
+
end
|
1643
|
+
|
1644
|
+
it "should parse type 'a' into an available state for a package" do
|
1645
|
+
@yc.available_version("znc").should_not be == nil
|
1646
|
+
@yc.installed_version("znc").should be == nil
|
1647
|
+
end
|
1648
|
+
|
1649
|
+
it "should parse type 'r' into an installed and available states for a package" do
|
1650
|
+
@yc.available_version("zip").should_not be == nil
|
1651
|
+
@yc.installed_version("zip").should_not be == nil
|
1652
|
+
end
|
1653
|
+
|
1654
|
+
it "should parse installonlypkgs from yum-dump.py options output" do
|
1655
|
+
@yc.allow_multi_install.should be == %w{kernel kernel-bigmem kernel-enterprise}
|
1656
|
+
end
|
1657
|
+
end
|
1658
|
+
|
1659
|
+
describe "installed_version" do
|
1660
|
+
it "should take one or two arguments" do
|
1661
|
+
lambda { @yc.installed_version("zip") }.should_not raise_error(ArgumentError)
|
1662
|
+
lambda { @yc.installed_version("zip", "i386") }.should_not raise_error(ArgumentError)
|
1663
|
+
lambda { @yc.installed_version("zip", "i386", "extra") }.should raise_error(ArgumentError)
|
1664
|
+
end
|
1665
|
+
|
1666
|
+
it "should return version-release for matching package regardless of arch" do
|
1667
|
+
@yc.installed_version("zip", "x86_64").should be == "2.31-2.el5"
|
1668
|
+
@yc.installed_version("zip", nil).should be == "2.31-2.el5"
|
1669
|
+
end
|
1670
|
+
|
1671
|
+
it "should return version-release for matching package and arch" do
|
1672
|
+
@yc.installed_version("zip", "x86_64").should be == "2.31-2.el5"
|
1673
|
+
@yc.installed_version("zisofs-tools", "i386").should be == nil
|
1674
|
+
end
|
1675
|
+
|
1676
|
+
it "should return nil for an unmatched package" do
|
1677
|
+
@yc.installed_version(nil, nil).should be == nil
|
1678
|
+
@yc.installed_version("test1", nil).should be == nil
|
1679
|
+
@yc.installed_version("test2", "x86_64").should be == nil
|
1680
|
+
end
|
1681
|
+
end
|
1682
|
+
|
1683
|
+
describe "available_version" do
|
1684
|
+
it "should take one or two arguments" do
|
1685
|
+
lambda { @yc.available_version("zisofs-tools") }.should_not raise_error(ArgumentError)
|
1686
|
+
lambda { @yc.available_version("zisofs-tools", "i386") }.should_not raise_error(ArgumentError)
|
1687
|
+
lambda { @yc.available_version("zisofs-tools", "i386", "extra") }.should raise_error(ArgumentError)
|
1688
|
+
end
|
1689
|
+
|
1690
|
+
it "should return version-release for matching package regardless of arch" do
|
1691
|
+
@yc.available_version("zip", "x86_64").should be == "2.31-2.el5"
|
1692
|
+
@yc.available_version("zip", nil).should be == "2.31-2.el5"
|
1693
|
+
end
|
1694
|
+
|
1695
|
+
it "should return version-release for matching package and arch" do
|
1696
|
+
@yc.available_version("zip", "x86_64").should be == "2.31-2.el5"
|
1697
|
+
@yc.available_version("zisofs-tools", "i386").should be == nil
|
1698
|
+
end
|
1699
|
+
|
1700
|
+
it "should return nil for an unmatched package" do
|
1701
|
+
@yc.available_version(nil, nil).should be == nil
|
1702
|
+
@yc.available_version("test1", nil).should be == nil
|
1703
|
+
@yc.available_version("test2", "x86_64").should be == nil
|
1704
|
+
end
|
1705
|
+
end
|
1706
|
+
|
1707
|
+
describe "version_available?" do
|
1708
|
+
it "should take two or three arguments" do
|
1709
|
+
lambda { @yc.version_available?("zisofs-tools") }.should raise_error(ArgumentError)
|
1710
|
+
lambda { @yc.version_available?("zisofs-tools", "1.0.6-3.2.2") }.should_not raise_error(ArgumentError)
|
1711
|
+
lambda { @yc.version_available?("zisofs-tools", "1.0.6-3.2.2", "x86_64") }.should_not raise_error(ArgumentError)
|
1712
|
+
end
|
1713
|
+
|
1714
|
+
it "should return true if our package-version-arch is available" do
|
1715
|
+
@yc.version_available?("zisofs-tools", "1.0.6-3.2.2", "x86_64").should be == true
|
1716
|
+
end
|
1717
|
+
|
1718
|
+
it "should return true if our package-version, no arch, is available" do
|
1719
|
+
@yc.version_available?("zisofs-tools", "1.0.6-3.2.2", nil).should be == true
|
1720
|
+
@yc.version_available?("zisofs-tools", "1.0.6-3.2.2").should be == true
|
1721
|
+
end
|
1722
|
+
|
1723
|
+
it "should return false if our package-version-arch isn't available" do
|
1724
|
+
@yc.version_available?("zisofs-tools", "1.0.6-3.2.2", "pretend").should be == false
|
1725
|
+
@yc.version_available?("zisofs-tools", "pretend", "x86_64").should be == false
|
1726
|
+
@yc.version_available?("pretend", "1.0.6-3.2.2", "x86_64").should be == false
|
1727
|
+
end
|
1728
|
+
|
1729
|
+
it "should return false if our package-version, no arch, isn't available" do
|
1730
|
+
@yc.version_available?("zisofs-tools", "pretend", nil).should be == false
|
1731
|
+
@yc.version_available?("zisofs-tools", "pretend").should be == false
|
1732
|
+
@yc.version_available?("pretend", "1.0.6-3.2.2").should be == false
|
1733
|
+
end
|
1734
|
+
end
|
1735
|
+
|
1736
|
+
describe "package_repository" do
|
1737
|
+
it "should take two or three arguments" do
|
1738
|
+
lambda { @yc.package_repository("zisofs-tools") }.should raise_error(ArgumentError)
|
1739
|
+
lambda { @yc.package_repository("zisofs-tools", "1.0.6-3.2.2") }.should_not raise_error(ArgumentError)
|
1740
|
+
lambda { @yc.package_repository("zisofs-tools", "1.0.6-3.2.2", "x86_64") }.should_not raise_error(ArgumentError)
|
1741
|
+
end
|
1742
|
+
|
1743
|
+
it "should return repoid for package-version-arch" do
|
1744
|
+
@yc.package_repository("zlib-devel", "1.2.3-3", "i386").should be == "extras"
|
1745
|
+
@yc.package_repository("zlib-devel", "1.2.3-3", "x86_64").should be == "base"
|
1746
|
+
end
|
1747
|
+
|
1748
|
+
it "should return repoid for package-version, no arch" do
|
1749
|
+
@yc.package_repository("zisofs-tools", "1.0.6-3.2.2", nil).should be == "extras"
|
1750
|
+
@yc.package_repository("zisofs-tools", "1.0.6-3.2.2").should be == "extras"
|
1751
|
+
end
|
1752
|
+
|
1753
|
+
it "should return nil when no match for package-version-arch" do
|
1754
|
+
@yc.package_repository("zisofs-tools", "1.0.6-3.2.2", "pretend").should be == nil
|
1755
|
+
@yc.package_repository("zisofs-tools", "pretend", "x86_64").should be == nil
|
1756
|
+
@yc.package_repository("pretend", "1.0.6-3.2.2", "x86_64").should be == nil
|
1757
|
+
end
|
1758
|
+
|
1759
|
+
it "should return nil when no match for package-version, no arch" do
|
1760
|
+
@yc.package_repository("zisofs-tools", "pretend", nil).should be == nil
|
1761
|
+
@yc.package_repository("zisofs-tools", "pretend").should be == nil
|
1762
|
+
@yc.package_repository("pretend", "1.0.6-3.2.2").should be == nil
|
1763
|
+
end
|
1764
|
+
end
|
1765
|
+
|
1766
|
+
describe "reset" do
|
1767
|
+
it "should empty the installed and available packages RPMDb" do
|
1768
|
+
@yc.available_version("zip", "x86_64").should be == "2.31-2.el5"
|
1769
|
+
@yc.installed_version("zip", "x86_64").should be == "2.31-2.el5"
|
1770
|
+
@yc.reset
|
1771
|
+
@yc.available_version("zip", "x86_64").should be == nil
|
1772
|
+
@yc.installed_version("zip", "x86_64").should be == nil
|
1773
|
+
end
|
1774
|
+
end
|
1775
|
+
|
1776
|
+
describe "package_available?" do
|
1777
|
+
it "should return true a package name is available" do
|
1778
|
+
@yc.package_available?("zisofs-tools").should be == true
|
1779
|
+
@yc.package_available?("moo").should be == false
|
1780
|
+
@yc.package_available?(nil).should be == false
|
1781
|
+
end
|
1782
|
+
|
1783
|
+
it "should return true a package name + arch is available" do
|
1784
|
+
@yc.package_available?("zlib-devel.i386").should be == true
|
1785
|
+
@yc.package_available?("zisofs-tools.x86_64").should be == true
|
1786
|
+
@yc.package_available?("znc-test.beta1.x86_64").should be == true
|
1787
|
+
@yc.package_available?("znc-test.beta1").should be == true
|
1788
|
+
@yc.package_available?("znc-test.test.beta1").should be == true
|
1789
|
+
@yc.package_available?("moo.i386").should be == false
|
1790
|
+
@yc.package_available?("zisofs-tools.beta").should be == false
|
1791
|
+
@yc.package_available?("znc-test.test").should be == false
|
1792
|
+
end
|
1793
|
+
end
|
1794
|
+
|
1795
|
+
end
|