summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-01-17 13:43:28 -0800
committerdanielsdeleo <dan@opscode.com>2013-01-17 15:02:54 -0800
commit62f9b0e3be8e22eef092163c331b7d3f8d350f94 (patch)
tree6b37c7a275918580b59c16de32a16c24f5dbe77f /spec
parent30ec971df95264b39e5e403c08b634d4708f5bee (diff)
parentb568c4d060765e75023f50f24d0a394ada5aed0b (diff)
downloadchef-62f9b0e3be8e22eef092163c331b7d3f8d350f94.tar.gz
Merge branch '10-stable' into integrate-chef-10-18-0
Conflicts: .gitattributes chef-expander/Rakefile chef-expander/lib/chef/expander/version.rb chef-server-api/Rakefile chef-server-api/chef-server-api.gemspec chef-server-api/lib/chef-server-api/version.rb chef-server-webui/Rakefile chef-server-webui/chef-server-webui.gemspec chef-server-webui/lib/chef-server-webui/version.rb chef-server/Rakefile chef-server/lib/chef-server/version.rb chef-solr/lib/chef/solr/version.rb chef.gemspec chef/Rakefile chef/spec/support/platform_helpers.rb chef/spec/support/shared/functional/file_resource.rb chef/spec/unit/api_client_spec.rb chef/spec/unit/provider/directory_spec.rb ci/jenkins_run_tests.bat ci/jenkins_run_tests.sh distro/common/html/chef-client.8.html distro/common/html/chef-expander.8.html distro/common/html/chef-expanderctl.8.html distro/common/html/chef-server-webui.8.html distro/common/html/chef-server.8.html distro/common/html/chef-shell.1.html distro/common/html/chef-solo.8.html distro/common/html/chef-solr.8.html distro/common/html/knife-bootstrap.1.html distro/common/html/knife-client.1.html distro/common/html/knife-configure.1.html distro/common/html/knife-cookbook-site.1.html distro/common/html/knife-cookbook.1.html distro/common/html/knife-data-bag.1.html distro/common/html/knife-environment.1.html distro/common/html/knife-exec.1.html distro/common/html/knife-index.1.html distro/common/html/knife-node.1.html distro/common/html/knife-role.1.html distro/common/html/knife-search.1.html distro/common/html/knife-ssh.1.html distro/common/html/knife-status.1.html distro/common/html/knife-tag.1.html distro/common/html/knife.1.html distro/common/man/man1/chef-shell.1 distro/common/man/man1/knife-bootstrap.1 distro/common/man/man1/knife-client.1 distro/common/man/man1/knife-configure.1 distro/common/man/man1/knife-cookbook-site.1 distro/common/man/man1/knife-cookbook.1 distro/common/man/man1/knife-data-bag.1 distro/common/man/man1/knife-environment.1 distro/common/man/man1/knife-exec.1 distro/common/man/man1/knife-index.1 distro/common/man/man1/knife-node.1 distro/common/man/man1/knife-role.1 distro/common/man/man1/knife-search.1 distro/common/man/man1/knife-ssh.1 distro/common/man/man1/knife-status.1 distro/common/man/man1/knife-tag.1 distro/common/man/man1/knife.1 distro/common/man/man8/chef-client.8 distro/common/man/man8/chef-expander.8 distro/common/man/man8/chef-expanderctl.8 distro/common/man/man8/chef-server-webui.8 distro/common/man/man8/chef-server.8 distro/common/man/man8/chef-solo.8 distro/common/man/man8/chef-solr.8 lib/chef/api_client.rb lib/chef/rest.rb lib/chef/version.rb spec/functional/knife/ssh_spec.rb spec/functional/resource/cookbook_file_spec.rb spec/spec_helper.rb spec/stress/win32/security_spec.rb spec/support/shared/functional/securable_resource.rb spec/unit/config_spec.rb spec/unit/knife/ssh_spec.rb
Diffstat (limited to 'spec')
-rw-r--r--spec/data/cookbooks/chefignore2
-rw-r--r--spec/functional/knife/ssh_spec.rb58
-rw-r--r--spec/stress/win32/security_spec.rb6
-rw-r--r--spec/support/matchers/leak.rb2
-rw-r--r--spec/unit/config_spec.rb7
-rw-r--r--spec/unit/cookbook/chefignore_spec.rb3
-rw-r--r--spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb20
-rw-r--r--spec/unit/knife/bootstrap_spec.rb97
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb7
-rw-r--r--spec/unit/provider/package/yum_spec.rb90
-rw-r--r--spec/unit/resource/log_spec.rb9
11 files changed, 257 insertions, 44 deletions
diff --git a/spec/data/cookbooks/chefignore b/spec/data/cookbooks/chefignore
index cfd4e65832..84b4f1e99f 100644
--- a/spec/data/cookbooks/chefignore
+++ b/spec/data/cookbooks/chefignore
@@ -4,3 +4,5 @@
#
recipes/ignoreme.rb
+ # comments can be indented
+ignored
diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb
index 53012ce56d..a853e8de19 100644
--- a/spec/functional/knife/ssh_spec.rb
+++ b/spec/functional/knife/ssh_spec.rb
@@ -23,6 +23,7 @@ describe Chef::Knife::Ssh do
before(:all) do
@original_config = Chef::Config.hash_dup
+ @original_knife_config = Chef::Config[:knife].dup
Chef::Knife::Ssh.load_deps
@server = TinyServer::Manager.new
@server.start
@@ -30,6 +31,7 @@ describe Chef::Knife::Ssh do
after(:all) do
Chef::Config.configuration = @original_config
+ Chef::Config[:knife] = @original_knife_config
@server.stop
end
@@ -89,6 +91,19 @@ describe Chef::Knife::Ssh do
end
end
+ describe "port" do
+ context "when -p 31337 is provided" do
+ before do
+ setup_knife(['-p 31337', '*:*', 'uptime'])
+ end
+
+ it "uses the ssh_port" do
+ @knife.run
+ @knife.config[:ssh_port].should == "31337"
+ end
+ end
+ end
+
describe "user" do
context "when knife[:ssh_user] is set" do
before do
@@ -192,6 +207,49 @@ describe Chef::Knife::Ssh do
end
end
+ describe "gateway" do
+ context "when knife[:ssh_gateway] is set" do
+ before do
+ setup_knife(['*:*', 'uptime'])
+ Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname"
+ end
+
+ it "uses the ssh_gateway" do
+ @knife.session.should_receive(:via).with("ec2.public_hostname", "user", {})
+ @knife.run
+ @knife.config[:ssh_gateway].should == "user@ec2.public_hostname"
+ end
+ end
+
+ context "when -G user@ec2.public_hostname is provided" do
+ before do
+ setup_knife(['-G user@ec2.public_hostname', '*:*', 'uptime'])
+ Chef::Config[:knife][:ssh_gateway] = nil
+ end
+
+ it "uses the ssh_gateway" do
+ @knife.session.should_receive(:via).with("ec2.public_hostname", "user", {})
+ @knife.run
+ @knife.config[:ssh_gateway].should == "user@ec2.public_hostname"
+ end
+ end
+
+ context "when the gateway requires a password" do
+ before do
+ setup_knife(['-G user@ec2.public_hostname', '*:*', 'uptime'])
+ Chef::Config[:knife][:ssh_gateway] = nil
+ @knife.session.stub(:via) do |host, user, options|
+ raise Net::SSH::AuthenticationFailed unless options[:password]
+ end
+ end
+
+ it "should prompt the user for a password" do
+ @knife.ui.should_receive(:ask).with("Enter the password for user@ec2.public_hostname: ").and_return("password")
+ @knife.run
+ end
+ end
+ end
+
def setup_knife(params=[])
@knife = Chef::Knife::Ssh.new(params)
# We explicitly avoid running #configure_chef, which would read a knife.rb
diff --git a/spec/stress/win32/security_spec.rb b/spec/stress/win32/security_spec.rb
index 515a49911f..e506b71be1 100644
--- a/spec/stress/win32/security_spec.rb
+++ b/spec/stress/win32/security_spec.rb
@@ -58,9 +58,9 @@ describe 'Chef::ReservedNames::Win32::Security', :windows_only do
it "should not leak when creating a new ACL and setting it on a file", :volatile do
securable_object = Security::SecurableObject.new(@monkeyfoo)
lambda {
- securable_object.dacl = Security::ACL.create([
- Chef::ReservedNames::Win32::Security::ACE.access_allowed(Security::SID.Everyone, Chef::ReservedNames::Win32::API::Security::GENERIC_READ),
- Chef::ReservedNames::Win32::Security::ACE.access_denied(Security::SID.from_account("Users"), Chef::ReservedNames::Win32::API::Security::GENERIC_ALL)
+ securable_object.dacl = Chef::ReservedNames::Win32::Security::ACL.create([
+ Chef::ReservedNames::Win32::Security::ACE.access_allowed(Chef::ReservedNames::Win32::Security::SID.Everyone, Chef::ReservedNames::Win32::API::Security::GENERIC_READ),
+ Chef::ReservedNames::Win32::Security::ACE.access_denied(Chef::ReservedNames::Win32::Security::SID.from_account("Users"), Chef::ReservedNames::Win32::API::Security::GENERIC_ALL)
])
GC.start
}.should_not leak_memory(:warmup => 50, :iterations => 100)
diff --git a/spec/support/matchers/leak.rb b/spec/support/matchers/leak.rb
index eb80fcd492..908770f042 100644
--- a/spec/support/matchers/leak.rb
+++ b/spec/support/matchers/leak.rb
@@ -60,7 +60,7 @@ module Matchers
def profiler
@profiler ||= begin
if Chef::Platform.windows?
- require File.join(File.dirname(__FILE__), '..', 'prof', 'win32')
+ require File.join(File.dirname(__FILE__), '..', 'platforms', 'prof', 'win32')
RSpec::Prof::Win32::Profiler.new
else
require File.join(File.dirname(__FILE__), '..', 'prof', 'gc')
diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb
index 927e7059b1..7b5d383ba3 100644
--- a/spec/unit/config_spec.rb
+++ b/spec/unit/config_spec.rb
@@ -104,7 +104,14 @@ describe Chef::Config do
@config_class.formatters.should == [[:doc, "/var/log/formatter.log"]]
end
+ end
+ context "when the url is a frozen string" do
+ before do
+ Chef::Config.chef_server_url = " https://junglist.gen.nz".freeze
+ end
+
+ it_behaves_like "server URL"
end
describe "class method: manage_secret_key" do
diff --git a/spec/unit/cookbook/chefignore_spec.rb b/spec/unit/cookbook/chefignore_spec.rb
index 30b97e865d..aacb60c012 100644
--- a/spec/unit/cookbook/chefignore_spec.rb
+++ b/spec/unit/cookbook/chefignore_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Cookbook::Chefignore do
end
it "loads the globs in the chefignore file" do
- @chefignore.ignores.should =~ %w[recipes/ignoreme.rb]
+ @chefignore.ignores.should =~ %w[recipes/ignoreme.rb ignored]
end
it "removes items from an array that match the ignores" do
@@ -32,6 +32,7 @@ describe Chef::Cookbook::Chefignore do
end
it "determines if a file is ignored" do
+ @chefignore.ignored?('ignored').should be_true
@chefignore.ignored?('recipes/ignoreme.rb').should be_true
@chefignore.ignored?('recipes/dontignoreme.rb').should be_false
end
diff --git a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
index 52c719d2fb..fa96845aca 100644
--- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb
@@ -112,6 +112,7 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
# fake code to run through #recipe_snippet
source_file = [ "if true", "var = non_existant", "end" ]
IO.stub!(:readlines).and_return(source_file)
+ File.stub!(:exists?).and_return(true)
end
it "parses a Windows path" do
@@ -127,6 +128,25 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do
@inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
@inspector.recipe_snippet.should match(/^# In \/home\/btm/)
end
+
+ context "when the recipe file does not exist" do
+ before do
+ File.stub!(:exists?).and_return(false)
+ IO.stub!(:readlines).and_raise(Errno::ENOENT)
+ end
+
+ it "does not try to parse a recipe in chef-shell/irb (CHEF-3411)" do
+ @resource.source_line = "(irb#1):1:in `irb_binding'"
+ @inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
+ @inspector.recipe_snippet.should be_nil
+ end
+
+ it "does not raise an exception trying to load a non-existant file (CHEF-3411)" do
+ @resource.source_line = "/somewhere/in/space"
+ @inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(@resource, :create, @exception)
+ lambda { @inspector.recipe_snippet }.should_not raise_error
+ end
+ end
end
describe "when examining a resource that confuses the parser" do
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index 98955d4f73..bbb63f8c01 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -134,36 +134,77 @@ describe Chef::Knife::Bootstrap do
@knife.name_args.first.should == "barf"
end
- describe "when configuring the underlying knife ssh command" do
- before do
- @knife.name_args = ["foo.example.com"]
- @knife.config[:ssh_user] = "rooty"
- @knife.config[:ssh_password] = "open_sesame"
- Chef::Config[:knife][:ssh_port] = "4001"
- @knife.config[:identity_file] = "~/.ssh/me.rsa"
- @knife.stub!(:read_template).and_return("")
- @knife_ssh = @knife.knife_ssh
- end
-
- it "configures the hostname" do
- @knife_ssh.name_args.first.should == "foo.example.com"
+ describe "when configuring the underlying knife ssh command"
+ context "from the command line" do
+ before do
+ @knife.name_args = ["foo.example.com"]
+ @knife.config[:ssh_user] = "rooty"
+ @knife.config[:ssh_port] = "4001"
+ @knife.config[:ssh_password] = "open_sesame"
+ Chef::Config[:knife][:ssh_user] = nil
+ Chef::Config[:knife][:ssh_port] = nil
+ @knife.config[:identity_file] = "~/.ssh/me.rsa"
+ @knife.stub!(:read_template).and_return("")
+ @knife_ssh = @knife.knife_ssh
+ end
+
+ it "configures the hostname" do
+ @knife_ssh.name_args.first.should == "foo.example.com"
+ end
+
+ it "configures the ssh user" do
+ @knife_ssh.config[:ssh_user].should == 'rooty'
+ end
+
+ it "configures the ssh password" do
+ @knife_ssh.config[:ssh_password].should == 'open_sesame'
+ end
+
+ it "configures the ssh port" do
+ @knife_ssh.config[:ssh_port].should == '4001'
+ end
+
+ it "configures the ssh identity file" do
+ @knife_ssh.config[:identity_file].should == '~/.ssh/me.rsa'
+ end
end
- it "configures the ssh user" do
- @knife_ssh.config[:ssh_user].should == 'rooty'
- end
-
- it "configures the ssh password" do
- @knife_ssh.config[:ssh_password].should == 'open_sesame'
- end
-
- it "configures the ssh port" do
- @knife_ssh.config[:ssh_port].should == '4001'
- end
-
- it "configures the ssh identity file" do
- @knife_ssh.config[:identity_file].should == '~/.ssh/me.rsa'
- end
+ context "from the knife config file" do
+ before do
+ @knife.name_args = ["config.example.com"]
+ @knife.config[:ssh_user] = nil
+ @knife.config[:ssh_port] = nil
+ @knife.config[:ssh_gateway] = nil
+ @knife.config[:identity_file] = nil
+ @knife.config[:host_key_verify] = nil
+ Chef::Config[:knife][:ssh_user] = "curiosity"
+ Chef::Config[:knife][:ssh_port] = "2430"
+ Chef::Config[:knife][:identity_file] = "~/.ssh/you.rsa"
+ Chef::Config[:knife][:ssh_gateway] = "towel.blinkenlights.nl"
+ Chef::Config[:knife][:host_key_verify] = true
+ @knife.stub!(:read_template).and_return("")
+ @knife_ssh = @knife.knife_ssh
+ end
+
+ it "configures the ssh user" do
+ @knife_ssh.config[:ssh_user].should == 'curiosity'
+ end
+
+ it "configures the ssh port" do
+ @knife_ssh.config[:ssh_port].should == '2430'
+ end
+
+ it "configures the ssh identity file" do
+ @knife_ssh.config[:identity_file].should == '~/.ssh/you.rsa'
+ end
+
+ it "configures the ssh gateway" do
+ @knife_ssh.config[:ssh_gateway].should == 'towel.blinkenlights.nl'
+ end
+
+ it "configures the host key verify mode" do
+ @knife_ssh.config[:host_key_verify].should == true
+ end
end
describe "when falling back to password auth when host key auth fails" do
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 6e1ce97f40..65c02beff0 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -56,6 +56,13 @@ describe Chef::Knife::Core::BootstrapContext do
@context.validation_key.should == IO.read(File.join(CHEF_SPEC_DATA, 'ssl', 'private_key.pem'))
end
+ it "reads the validation key when it contains a ~" do
+ IO.should_receive(:read).with(File.expand_path("my.key", ENV['HOME']))
+ @chef_config = {:validation_key => '~/my.key'}
+ @context = Chef::Knife::Core::BootstrapContext.new(@config, @run_list, @chef_config)
+ @context.validation_key
+ end
+
it "generates the config file data" do
expected=<<-EXPECTED
log_level :auto
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
index 4b890b1549..375ae0966b 100644
--- a/spec/unit/provider/package/yum_spec.rb
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -34,7 +34,8 @@ describe Chef::Provider::Package::Yum do
:package_available? => true,
:version_available? => true,
:allow_multi_install => [ "kernel" ],
- :package_repository => "base"
+ :package_repository => "base",
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -92,6 +93,7 @@ describe Chef::Provider::Package::Yum do
end
end
@yum_cache.stub!(:package_available?).and_return(true)
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
@@ -125,6 +127,7 @@ describe Chef::Provider::Package::Yum do
nil
end
@yum_cache.stub!(:package_available?).and_return(true)
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
# annoying side effect of the fun stub'ing above
@@ -155,6 +158,7 @@ describe Chef::Provider::Package::Yum do
nil
end
@yum_cache.stub!(:package_available?).and_return(true)
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
@@ -189,6 +193,7 @@ describe Chef::Provider::Package::Yum do
end
end.and_return("something")
@yum_cache.stub!(:package_available?).and_return(true)
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@provider.load_current_resource
@@ -209,6 +214,24 @@ describe Chef::Provider::Package::Yum do
@provider.load_current_resource
end
+ it "should detect --enablerepo or --disablerepo when passed among options, collect them preserving order and notify the yum cache" do
+ @new_resource.stub!(:options).and_return("--stuff --enablerepo=foo --otherthings --disablerepo=a,b,c --enablerepo=bar")
+ @yum_cache.should_receive(:enable_extra_repo_control).with("--enablerepo=foo --disablerepo=a,b,c --enablerepo=bar")
+ @provider.load_current_resource
+ end
+
+ it "should let the yum cache know extra repos are disabled if --enablerepo or --disablerepo aren't among options" do
+ @new_resource.stub!(:options).and_return("--stuff --otherthings")
+ @yum_cache.should_receive(:disable_extra_repo_control)
+ @provider.load_current_resource
+ end
+
+ it "should let the yum cache know extra repos are disabled if options aren't set" do
+ @new_resource.stub!(:options).and_return(nil)
+ @yum_cache.should_receive(:disable_extra_repo_control)
+ @provider.load_current_resource
+ end
+
it "should search provides if package name can't be found then set package_name to match" do
@yum_cache = mock(
'Chef::Provider::Yum::YumCache',
@@ -217,7 +240,8 @@ describe Chef::Provider::Package::Yum do
:installed_version => "1.2.4-11.18.el5",
:candidate_version => "1.2.4-11.18.el5",
:package_available? => false,
- :version_available? => true
+ :version_available? => true,
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "1.2.4-11.18.el5", "x86_64", [])
@@ -235,7 +259,8 @@ describe Chef::Provider::Package::Yum do
:installed_version => "1.2.4-11.18.el5",
:candidate_version => "1.2.4-11.18.el5",
:package_available? => false,
- :version_available? => true
+ :version_available? => true,
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
pkg_x = Chef::Provider::Package::Yum::RPMPackage.new("test-package-x", "1.2.4-11.18.el5", "x86_64", [])
@@ -255,7 +280,8 @@ describe Chef::Provider::Package::Yum do
:installed_version => "1.2.4-11.18.el5",
:candidate_version => "1.2.4-11.18.el5",
:package_available? => false,
- :version_available? => true
+ :version_available? => true,
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@yum_cache.should_receive(:packages_from_require).twice.and_return([])
@@ -272,7 +298,8 @@ describe Chef::Provider::Package::Yum do
:installed_version => "1.2.4-11.18.el5",
:candidate_version => "1.2.4-11.18.el5",
:package_available? => false,
- :version_available? => true
+ :version_available? => true,
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -295,7 +322,8 @@ describe Chef::Provider::Package::Yum do
:installed_version => "1.2.4-11.18.el5",
:candidate_version => "1.2.4-11.18.el5",
:package_available? => false,
- :version_available? => true
+ :version_available? => true,
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@yum_cache.should_receive(:packages_from_require).twice.and_return([])
@@ -363,7 +391,8 @@ describe Chef::Provider::Package::Yum do
:installed_version => "1.2.4-11.18.el5",
:candidate_version => "1.2.4-11.18.el5_2.3",
:package_available? => true,
- :version_available? => nil
+ :version_available? => nil,
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -380,7 +409,8 @@ describe Chef::Provider::Package::Yum do
:candidate_version => "1.2.4-11.15.el5",
:package_available? => true,
:version_available? => true,
- :allow_multi_install => [ "kernel" ]
+ :allow_multi_install => [ "kernel" ],
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -398,7 +428,8 @@ describe Chef::Provider::Package::Yum do
:package_available? => true,
:version_available? => true,
:allow_multi_install => [ "cups" ],
- :package_repository => "base"
+ :package_repository => "base",
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -420,7 +451,8 @@ describe Chef::Provider::Package::Yum do
:package_available? => true,
:version_available? => true,
:allow_multi_install => [],
- :package_repository => "base"
+ :package_repository => "base",
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -485,7 +517,8 @@ describe Chef::Provider::Package::Yum do
:candidate_version => "1.2.4-11.15.el5",
:package_available? => true,
:version_available? => true,
- :allow_multi_install => [ "kernel" ]
+ :allow_multi_install => [ "kernel" ],
+ :disable_extra_repo_control => true
)
Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
@provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -1609,6 +1642,12 @@ EOF
@yc.refresh
end
+ it "should pass extra_repo_control args to yum-dump.py" do
+ @yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar")
+ @yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar$}, :waitlast=>true)
+ @yc.refresh
+ end
+
it "should warn about invalid data with too many separators" do
@yc.stub!(:popen4).and_yield(@pid, @stdin, @stdout_bad_separators, @stderr).and_return(@status)
Chef::Log.should_receive(:warn).exactly(3).times.with(%r{Problem parsing})
@@ -1788,4 +1827,33 @@ EOF
end
end
+ describe "enable_extra_repo_control" do
+ it "should set @extra_repo_control to arg" do
+ @yc.enable_extra_repo_control("--enablerepo=test")
+ @yc.extra_repo_control.should be == "--enablerepo=test"
+ end
+
+ it "should call reload once when set to flag cache for update" do
+ @yc.should_receive(:reload).once
+ @yc.enable_extra_repo_control("--enablerepo=test")
+ @yc.enable_extra_repo_control("--enablerepo=test")
+ end
+ end
+
+ describe "disable_extra_repo_control" do
+ it "should set @extra_repo_control to nil" do
+ @yc.enable_extra_repo_control("--enablerepo=test")
+ @yc.disable_extra_repo_control
+ @yc.extra_repo_control.should be == nil
+ end
+
+ it "should call reload once when cleared to flag cache for update" do
+ @yc.should_receive(:reload).once
+ @yc.enable_extra_repo_control("--enablerepo=test")
+ @yc.should_receive(:reload).once
+ @yc.disable_extra_repo_control
+ @yc.disable_extra_repo_control
+ end
+ end
+
end
diff --git a/spec/unit/resource/log_spec.rb b/spec/unit/resource/log_spec.rb
index bc5ac13078..4c6b2c122d 100644
--- a/spec/unit/resource/log_spec.rb
+++ b/spec/unit/resource/log_spec.rb
@@ -38,6 +38,15 @@ describe Chef::Resource::Log do
it "should allow you to set a log string" do
@resource.name.should == @log_str
end
+
+ it "should set the message to the first argument to new" do
+ @resource.message.should == @log_str
+ end
+
+ it "should accept a string for the log message" do
+ @resource.message "this is different"
+ @resource.message.should == "this is different"
+ end
it "should accept a vaild level option" do
@resource.level :debug