From 1070b3c6e30e75ef554b6ca5ffe24191f999fba1 Mon Sep 17 00:00:00 2001 From: Luke Kanies <luke@madstop.com> Date: Sat, 14 Feb 2009 09:30:26 -0600 Subject: Fixing a test broken by a log demotion Signed-off-by: Luke Kanies <luke@madstop.com> --- spec/unit/network/xmlrpc/client.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/unit/network/xmlrpc/client.rb b/spec/unit/network/xmlrpc/client.rb index 36e59429c..328688bae 100755 --- a/spec/unit/network/xmlrpc/client.rb +++ b/spec/unit/network/xmlrpc/client.rb @@ -109,7 +109,7 @@ describe Puppet::Network::XMLRPCClient do it "should log, recycle the connection, and retry if Errno::EPIPE is raised" do @client.expects(:call).times(2).raises(Errno::EPIPE).then.returns "eh" - Puppet.expects(:warning) + Puppet.expects(:info) @client.expects(:recycle_connection) @client.report("eh") @@ -118,7 +118,7 @@ describe Puppet::Network::XMLRPCClient do it "should log, recycle the connection, and retry if EOFError is raised" do @client.expects(:call).times(2).raises(EOFError).then.returns "eh" - Puppet.expects(:warning) + Puppet.expects(:info) @client.expects(:recycle_connection) @client.report("eh") -- cgit From 44f97aa5815d4a8ab73302bd75b85e045f9944c4 Mon Sep 17 00:00:00 2001 From: Luke Kanies <luke@madstop.com> Date: Sat, 14 Feb 2009 11:43:25 -0600 Subject: Only backing up within parsedfile when managing files I was getting failing tests because I was using non-files for testing and they didn't back up the same, not surprisingly. This moves the 'backup' method to the :flat filetype and then only backs up if the filetype supports it. Signed-off-by: Luke Kanies <luke@madstop.com> --- spec/unit/provider/parsedfile.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/unit/provider/parsedfile.rb b/spec/unit/provider/parsedfile.rb index 11a91c8d7..f20b6b235 100755 --- a/spec/unit/provider/parsedfile.rb +++ b/spec/unit/provider/parsedfile.rb @@ -56,18 +56,27 @@ describe Puppet::Provider::ParsedFile do @class.initvars @class.prefetch - @filetype = mock 'filetype' - Puppet::Util::FileType.filetype(:flat).expects(:new).with("/my/file").returns @filetype + @filetype = Puppet::Util::FileType.filetype(:flat).new("/my/file") + Puppet::Util::FileType.filetype(:flat).stubs(:new).with("/my/file").returns @filetype @filetype.stubs(:write) end - it "should back up the file being written" do + it "should back up the file being written if the filetype can be backed up" do @filetype.expects(:backup) @class.flush_target("/my/file") end + it "should not try to back up the file if the filetype cannot be backed up" do + @filetype = Puppet::Util::FileType.filetype(:ram).new("/my/file") + Puppet::Util::FileType.filetype(:flat).expects(:new).returns @filetype + + @filetype.stubs(:write) + + @class.flush_target("/my/file") + end + it "should not back up the file more than once between calls to 'prefetch'" do @filetype.expects(:backup).once -- cgit From 682dd8b933c5feeed389b644b75f27e66e863276 Mon Sep 17 00:00:00 2001 From: Luke Kanies <luke@madstop.com> Date: Sat, 14 Feb 2009 11:55:20 -0600 Subject: Fixing password validation to support symbols. My fix for #1920 broke when you set :absent or :present. Signed-off-by: Luke Kanies <luke@madstop.com> --- spec/unit/type/user.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/unit/type/user.rb b/spec/unit/type/user.rb index 15a3e2532..dadcc65ef 100755 --- a/spec/unit/type/user.rb +++ b/spec/unit/type/user.rb @@ -40,10 +40,6 @@ describe user do it "should have a valid provider" do user.create(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider) end - - it "should fail if a ':' is included in the password" do - lambda { user.create(:name => "foo", :password => 'some:thing') }.should raise_error(Puppet::Error) - end end properties = [:ensure, :uid, :gid, :home, :comment, :shell, :password, :groups, :roles, :auths, :profiles, :project, :keys] @@ -235,6 +231,14 @@ describe user do it "should not include the password in the change log when changing the password" do @password.change_to_s("other", "mypass").should_not be_include("mypass") end + + it "should fail if a ':' is included in the password" do + lambda { @password.should = "some:thing" }.should raise_error(ArgumentError) + end + + it "should allow the value to be set to :absent" do + lambda { @password.should = :absent }.should_not raise_error + end end describe "when manages_solaris_rbac is enabled" do -- cgit From 446989b6932e4a2324b9202fa05114046a6fb5df Mon Sep 17 00:00:00 2001 From: Nigel Kersten <nigelk@google.com> Date: Sat, 14 Feb 2009 08:07:51 -0800 Subject: Fix spec test for launchd service provider to work with new service status method and add two new status tests. Now ensures that given the correct input, the correct status for the launchd service is returned. --- spec/unit/provider/service/launchd.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/unit/provider/service/launchd.rb b/spec/unit/provider/service/launchd.rb index cc2dae190..f2d69a47b 100755 --- a/spec/unit/provider/service/launchd.rb +++ b/spec/unit/provider/service/launchd.rb @@ -62,9 +62,17 @@ describe provider_class do describe "when checking status" do it "should call the external command 'launchctl list' once" do - @provider.expects(:launchctl).with(:list, @resource[:name]).returns(:running).once + @provider.expects(:launchctl).with(:list).returns("rotating-strawberry-madonnas") @provider.status end + it "should return stopped if not listed in launchctl list output" do + @provider.stubs(:launchctl).with(:list).returns("rotating-strawberry-madonnas") + assert_equal @provider.status, :stopped + end + it "should return running if listed in launchctl list output" do + @provider.stubs(:launchctl).with(:list).returns(@joblabel) + assert_equal @provider.status, :running + end end describe "when starting the service" do -- cgit