diff options
Diffstat (limited to 'spec/unit/type')
-rwxr-xr-x | spec/unit/type/file.rb | 2 | ||||
-rwxr-xr-x | spec/unit/type/group.rb | 3 | ||||
-rwxr-xr-x | spec/unit/type/noop_metaparam.rb | 1 | ||||
-rwxr-xr-x | spec/unit/type/ssh_authorized_key.rb | 39 | ||||
-rwxr-xr-x | spec/unit/type/tidy.rb | 15 | ||||
-rwxr-xr-x | spec/unit/type/user.rb | 3 |
6 files changed, 54 insertions, 9 deletions
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb index 0187cc41d..094596966 100755 --- a/spec/unit/type/file.rb +++ b/spec/unit/type/file.rb @@ -4,6 +4,8 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe Puppet::Type.type(:file) do before do + Puppet.settings.stubs(:use) + @path = Tempfile.new("puppetspec") pathname = @path.path @path.close!() diff --git a/spec/unit/type/group.rb b/spec/unit/type/group.rb index c9a7fc904..fad7a0c48 100755 --- a/spec/unit/type/group.rb +++ b/spec/unit/type/group.rb @@ -4,6 +4,9 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe Puppet::Type.type(:group) do before do + unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin") + ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" + end @class = Puppet::Type.type(:group) end diff --git a/spec/unit/type/noop_metaparam.rb b/spec/unit/type/noop_metaparam.rb index 98cb0409e..2c4b6dc49 100755 --- a/spec/unit/type/noop_metaparam.rb +++ b/spec/unit/type/noop_metaparam.rb @@ -6,6 +6,7 @@ require 'puppet/type' describe Puppet::Type.type(:file).attrclass(:noop) do before do + Puppet.settings.stubs(:use) @file = Puppet::Type.newfile :path => "/what/ever" end diff --git a/spec/unit/type/ssh_authorized_key.rb b/spec/unit/type/ssh_authorized_key.rb index 9a2389eef..db389864e 100755 --- a/spec/unit/type/ssh_authorized_key.rb +++ b/spec/unit/type/ssh_authorized_key.rb @@ -89,13 +89,36 @@ describe ssh_authorized_key do @class.attrtype(:target).should == :property end - it "should raise an error when neither user nor target is given" do - proc do - @class.new( - :name => "Test", - :key => "AAA", - :type => "ssh-rsa", - :ensure => :present) - end.should raise_error(Puppet::Error) + describe "when neither user nor target is specified" do + it "should raise an error" do + proc do + @class.create( + :name => "Test", + :key => "AAA", + :type => "ssh-rsa", + :ensure => :present) + end.should raise_error(Puppet::Error) + end + end + + describe "when both target and user are specified" do + it "should use target" do + resource = @class.create( + :name => "Test", + :user => "root", + :target => "/tmp/blah") + resource.should(:target).should == "/tmp/blah" + end + end + + + describe "when user is specified" do + it "should determine target" do + resource = @class.create( + :name => "Test", + :user => "root") + target = File.expand_path("~root/.ssh/authorized_keys") + resource.should(:target).should == target + end end end diff --git a/spec/unit/type/tidy.rb b/spec/unit/type/tidy.rb index 72f6b0f10..e17f65de4 100755 --- a/spec/unit/type/tidy.rb +++ b/spec/unit/type/tidy.rb @@ -2,13 +2,26 @@ require File.dirname(__FILE__) + '/../../spec_helper' -describe Puppet::Type.type(:tidy) do +tidy = Puppet::Type.type(:tidy) + +describe tidy do + before do + Puppet.settings.stubs(:use) + end + it "should use :lstat when stating a file" do tidy = Puppet::Type.type(:tidy).new :path => "/foo/bar", :age => "1d" stat = mock 'stat' File.expects(:lstat).with("/foo/bar").returns stat tidy.stat("/foo/bar").should == stat end + + it "should be in sync if the targeted file does not exist" do + File.expects(:lstat).with("/tmp/foonesslaters").raises Errno::ENOENT + @tidy = tidy.create :path => "/tmp/foonesslaters", :age => "100d" + + @tidy.property(:ensure).must be_insync({}) + end [:age, :size, :path, :matches, :type, :recurse, :rmdirs].each do |param| it "should have a %s parameter" % param do diff --git a/spec/unit/type/user.rb b/spec/unit/type/user.rb index 57af7f093..bf2af23ab 100755 --- a/spec/unit/type/user.rb +++ b/spec/unit/type/user.rb @@ -6,6 +6,9 @@ user = Puppet::Type.type(:user) describe user do before do + unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin") + ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" + end @provider = stub 'provider' @resource = stub 'resource', :resource => nil, :provider => @provider, :line => nil, :file => nil end |