summaryrefslogtreecommitdiff
path: root/spec/unit/provider/mount
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/mount')
-rw-r--r--spec/unit/provider/mount/mount_spec.rb33
-rw-r--r--spec/unit/provider/mount/solaris_spec.rb4
2 files changed, 33 insertions, 4 deletions
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index b61dc65800..cd663b9684 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -53,13 +53,13 @@ describe Chef::Provider::Mount::Mount do
expect(@provider.current_resource.device).to eq("/dev/sdz1")
end
- it "should accecpt device_type :uuid", :not_supported_on_solaris do
+ it "should accept device_type :uuid", :not_supported_on_solaris do
@status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1)
@new_resource.device_type :uuid
@new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
@stdout_findfs = double("STDOUT", :first => "/dev/sdz1")
expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(@status)
- @provider.load_current_resource()
+ @provider.load_current_resource
@provider.mountable?
end
@@ -492,5 +492,34 @@ describe Chef::Provider::Mount::Mount do
@provider.disable_fs
end
end
+
+ # the fstab might contain the mount with the device as a device but the resource has a label.
+ # we should not create two mount lines, but update the existing one
+ context "when the device is described differently" do
+ it "should update the existing line" do
+ @current_resource.enabled(true)
+ status = double(:stdout => "/dev/sdz1\n", :exitstatus => 1)
+ expect(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status)
+
+ filesystems = [%q{/dev/sdy1 /tmp/foo ext3 defaults 1 2},
+ %q{/dev/sdz1 /tmp/foo ext3 defaults 1 2}].join("\n")
+ fstab = StringIO.new filesystems
+
+ fstab_write = StringIO.new
+
+ allow(::File).to receive(:readlines).with("/etc/fstab").and_return(fstab.readlines)
+ allow(::File).to receive(:open).with("/etc/fstab", "w").and_yield(fstab_write)
+ allow(::File).to receive(:open).with("/etc/fstab", "a").and_yield(fstab_write)
+
+ @new_resource.device_type :uuid
+ @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a"
+ @new_resource.dump 1
+
+ @provider.enable_fs
+ expect(fstab_write.string).to match(%r{/dev/sdy1\s+/tmp/foo\s+ext3\s+defaults\s+1\s+2})
+ expect(fstab_write.string).to match(%r{UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a\s+/tmp/foo\s+ext3\s+defaults\s+1\s+2})
+ expect(fstab_write.string).not_to match(%r{/dev/sdz1\s+/tmp/foo\s+ext3\s+defaults\s+1\s+2})
+ end
+ end
end
end
diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb
index 264c8b9b36..2ec9feaf3b 100644
--- a/spec/unit/provider/mount/solaris_spec.rb
+++ b/spec/unit/provider/mount/solaris_spec.rb
@@ -538,7 +538,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "after the mount's state has been discovered" do
describe "mount_fs" do
it "should mount the filesystem" do
- expect(provider).to receive(:shell_out!).with("mount -F #{fstype} -o defaults #{device} #{mountpoint}")
+ expect(provider).to receive(:shell_out!).with("mount -F #{fstype} #{device} #{mountpoint}")
provider.mount_fs()
end
@@ -600,7 +600,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do
context "in the typical case" do
let(:other_mount) { "/dev/dsk/c0t2d0s0 /dev/rdsk/c0t2d0s0 / ufs 2 yes -" }
- let(:this_mount) { "/dev/dsk/c0t2d0s7\t/dev/rdsk/c0t2d0s7\t/mnt/foo\tufs\t2\tyes\tdefaults\n" }
+ let(:this_mount) { "/dev/dsk/c0t2d0s7\t/dev/rdsk/c0t2d0s7\t/mnt/foo\tufs\t2\tyes\t-\n" }
let(:vfstab_file_contents) { [other_mount].join("\n") }