spec/unit/provider/mount_spec.rb in puppet-2.6.6 vs spec/unit/provider/mount_spec.rb in puppet-2.6.7
- old
+ new
@@ -17,26 +17,21 @@
@mounter.stubs(:resource).returns(@resource)
end
describe Puppet::Provider::Mount, " when mounting" do
+ before :each do
+ @mounter.stubs(:get).with(:ensure).returns(:mounted)
+ end
+
it "should use the 'mountcmd' method to mount" do
@mounter.stubs(:options).returns(nil)
@mounter.expects(:mountcmd)
@mounter.mount
end
- it "should flush before mounting if a flush method exists" do
- @mounter.meta_def(:flush) { }
- @mounter.expects(:flush)
- @mounter.stubs(:mountcmd)
- @mounter.stubs(:options).returns(nil)
-
- @mounter.mount
- end
-
it "should add the options following '-o' if they exist and are not set to :absent" do
@mounter.stubs(:options).returns("ro")
@mounter.expects(:mountcmd).with { |*ary| ary[0] == "-o" and ary[1] == "ro" }
@mounter.mount
@@ -46,10 +41,27 @@
@mounter.stubs(:options).returns(nil)
@mounter.expects(:mountcmd).with { |*ary| ary[-1] == @name }
@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
it "should use '-o remount' if the resource specifies it supports remounting" do
@@ -75,71 +87,60 @@
end
end
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
- 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("")
-
- @mounter.mounted?
+ 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 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")
-
- @mounter.should be_mounted
+ 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
- it "should match ' on <name>' if the operating system is Darwin" do
- Facter.stubs(:value).with("operatingsystem").returns("Darwin")
- @mounter.expects(:mountcmd).returns("/dev/disk03 on / (local, journaled)\ndevfs on /dev")
+ end
- @mounter.should be_mounted
- end
+ describe Puppet::Provider::Mount, " when determining if it is mounted" do
- it "should match '^<name> on' if the operating system is Solaris" do
- Facter.stubs(:value).with("operatingsystem").returns("Solaris")
- @mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
-
- @mounter.should be_mounted
+ it "should query the property_hash" do
+ @mounter.expects(:get).with(:ensure).returns(:mounted)
+ @mounter.mounted?
end
- it "should match '^<name> on' if the operating system is HP-UX" do
- Facter.stubs(:value).with("operatingsystem").returns("HP-UX")
- @mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
-
- @mounter.should be_mounted
+ it "should return true if prefetched value is :mounted" do
+ @mounter.stubs(:get).with(:ensure).returns(:mounted)
+ @mounter.mounted? == true
end
- it "should match mounted devices if the operating system is AIX" do
- Facter.stubs(:value).with("operatingsystem").returns("AIX")
- mount_data = File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'unit', 'provider', 'mount', 'mount-output.aix.txt'))
- @mounter.expects(:mountcmd).returns(mount_data)
-
- @mounter.should be_mounted
+ it "should return true if prefetched value is :ghost" do
+ @mounter.stubs(:get).with(:ensure).returns(:ghost)
+ @mounter.mounted? == true
end
- it "should match ' on <name>' if the operating system is not Darwin, Solaris, or HP-UX" do
- Facter.stubs(:value).with("operatingsystem").returns("Debian")
- @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on / and stuff\n/dev/other/disk on /var and stuff")
-
- @mounter.should be_mounted
+ it "should return false if prefetched value is :absent" do
+ @mounter.stubs(:get).with(:ensure).returns(:absent)
+ @mounter.mounted? == false
end
- it "should not be considered mounted if it did not match the mount output" do
- Facter.stubs(:value).with("operatingsystem").returns("Debian")
- @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on /something/else and stuff\n/dev/other/disk on /var and stuff")
-
- @mounter.should_not be_mounted
+ it "should return false if prefetched value is :unmounted" do
+ @mounter.stubs(:get).with(:ensure).returns(:unmounted)
+ @mounter.mounted? == false
end
+
end
+
end