summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMaxime Caumartin <maxime@passwordbox.com>2014-03-28 15:14:48 -0700
committerBryan McLellan <btm@getchef.com>2014-03-28 15:14:48 -0700
commitcca1430d6992872701051d08268cb3bc87c97cef (patch)
treecaef48c821c740c544586beee84cb89f4e318a2a /spec
parent21b7a98c5531b9dcede6ff8e6aa44830afd23b9e (diff)
downloadchef-cca1430d6992872701051d08268cb3bc87c97cef.tar.gz
CHEF-4957: Mount resource won't work when device is a relative symlink
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/mount/mount_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index 99e78590f1..e27cf71e01 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -141,6 +141,17 @@ describe Chef::Provider::Mount::Mount do
@provider.current_resource.mounted.should be_true
end
+ it "should set mounted true if the symlink target of the device is relative and is found in the mounts list - CHEF-4957" do
+ target = "xsdz1"
+
+ ::File.stub(:symlink?).with("#{@new_resource.device}").and_return(true)
+ ::File.stub(:readlink).with("#{@new_resource.device}").and_return(target)
+
+ @provider.stub(:shell_out!).and_return(OpenStruct.new(:stdout => "/dev/xsdz1 on /tmp/foo type ext3 (rw)\n"))
+ @provider.load_current_resource()
+ @provider.current_resource.mounted.should be_true
+ end
+
it "should set mounted true if the mount point is found last in the mounts list" do
mount = "/dev/sdy1 on #{@new_resource.mount_point} type ext3 (rw)\n"
mount << "#{@new_resource.device} on #{@new_resource.mount_point} type ext3 (rw)\n"
@@ -199,6 +210,20 @@ describe Chef::Provider::Mount::Mount do
@provider.current_resource.enabled.should be_true
end
+ it "should set enabled to true if the symlink target is relative and is in fstab - CHEF-4957" do
+ target = "xsdz1"
+
+ ::File.stub(:symlink?).with("#{@new_resource.device}").and_return(true)
+ ::File.stub(:readlink).with("#{@new_resource.device}").and_return(target)
+
+ fstab = "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n"
+
+ ::File.stub(:foreach).with("/etc/fstab").and_yield fstab
+
+ @provider.load_current_resource
+ @provider.current_resource.enabled.should be_true
+ end
+
it "should set enabled to false if the mount point is not in fstab" do
fstab = "/dev/sdy1 #{@new_resource.mount_point} ext3 defaults 1 2\n"
::File.stub(:foreach).with("/etc/fstab").and_yield fstab