diff options
author | Stefan Schulte <stefan.schulte@taunusstein.net> | 2011-01-25 20:45:54 +0100 |
---|---|---|
committer | Stefan Schulte <stefan.schulte@taunusstein.net> | 2011-01-25 21:23:35 +0100 |
commit | f534470221fb97f2d25700f01c3f8c43aef73c26 (patch) | |
tree | 6509fcc0497d17656ba64447991980ed57577755 | |
parent | b7530389788effce9705e34c75aab5aad1ad5ee6 (diff) | |
download | puppet-f534470221fb97f2d25700f01c3f8c43aef73c26.tar.gz puppet-f534470221fb97f2d25700f01c3f8c43aef73c26.tar.xz puppet-f534470221fb97f2d25700f01c3f8c43aef73c26.zip |
(#4914) Add specs for modified mount provider
Change specs
- No need to call flush before mounting (explicitly),
because the type and syncothers will to that for us
- Add tests regarding the prefetched mount status
-rwxr-xr-x | spec/unit/provider/mount_spec.rb | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb index b034214ee..232c559f4 100755 --- a/spec/unit/provider/mount_spec.rb +++ b/spec/unit/provider/mount_spec.rb @@ -19,18 +19,13 @@ describe Puppet::Provider::Mount do describe Puppet::Provider::Mount, " when mounting" do - it "should use the 'mountcmd' method to mount" do - @mounter.stubs(:options).returns(nil) - @mounter.expects(:mountcmd) - - @mounter.mount + before :each do + @mounter.stubs(:get).with(:ensure).returns(:mounted) end - it "should flush before mounting if a flush method exists" do - @mounter.meta_def(:flush) { } - @mounter.expects(:flush) - @mounter.stubs(:mountcmd) + it "should use the 'mountcmd' method to mount" do @mounter.stubs(:options).returns(nil) + @mounter.expects(:mountcmd) @mounter.mount end @@ -48,6 +43,23 @@ describe Puppet::Provider::Mount do @mounter.mount end + + it "should update the :ensure state to :mounted if it was :unmounted before" do + @mounter.expects(:mountcmd) + @mounter.stubs(:options).returns(nil) + @mounter.expects(:get).with(:ensure).returns(:unmounted) + @mounter.expects(:set).with(:ensure => :mounted) + @mounter.mount + end + + it "should update the :ensure state to :ghost if it was :absent before" do + @mounter.expects(:mountcmd) + @mounter.stubs(:options).returns(nil) + @mounter.expects(:get).with(:ensure).returns(:absent) + @mounter.expects(:set).with(:ensure => :ghost) + @mounter.mount + end + end describe Puppet::Provider::Mount, " when remounting" do @@ -77,21 +89,42 @@ describe Puppet::Provider::Mount do describe Puppet::Provider::Mount, " when unmounting" do + before :each do + @mounter.stubs(:get).with(:ensure).returns(:unmounted) + end + it "should call the :umount command with the resource name" do @mounter.expects(:umount).with(@name) @mounter.unmount end + + it "should update the :ensure state to :absent if it was :ghost before" do + @mounter.expects(:umount).with(@name).returns true + @mounter.expects(:get).with(:ensure).returns(:ghost) + @mounter.expects(:set).with(:ensure => :absent) + @mounter.unmount + end + + it "should update the :ensure state to :unmounted if it was :mounted before" do + @mounter.expects(:umount).with(@name).returns true + @mounter.expects(:get).with(:ensure).returns(:mounted) + @mounter.expects(:set).with(:ensure => :unmounted) + @mounter.unmount + end + end describe Puppet::Provider::Mount, " when determining if it is mounted" do - it "should parse the results of running the mount command with no arguments" do - Facter.stubs(:value).returns("whatever") - @mounter.expects(:mountcmd).returns("") - + it "should query the property_hash" do + @mounter.expects(:get).with(:ensure).returns(:mounted) @mounter.mounted? end + end + + describe Puppet::Provider::Mount, " when prefetching resources" do + it "should match ' on /private/var/automount<name>' if the operating system is Darwin" do Facter.stubs(:value).with("operatingsystem").returns("Darwin") @mounter.expects(:mountcmd).returns("/dev/whatever on /private/var/automount/\ndevfs on /dev") |