|
49 | 49 | @provider.current_resource.mount_point.should == '/tmp/foo' |
50 | 50 | @provider.current_resource.device.should == '/dev/sdz1' |
51 | 51 | end |
| 52 | + |
| 53 | + it "should accecpt device_type :uuid" do |
| 54 | + @new_resource.device_type :uuid |
| 55 | + @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" |
| 56 | + @stdout_findfs = mock("STDOUT", :first => "/dev/sdz1") |
| 57 | + @provider.should_receive(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,@stdout_findfs,@stderr).and_return(@status) |
| 58 | + @provider.load_current_resource() |
| 59 | + end |
52 | 60 |
|
53 | 61 | it "should raise an error if the mount device does not exist" do |
54 | 62 | ::File.stub!(:exists?).with("/dev/sdz1").and_return false |
55 | 63 | lambda { @provider.load_current_resource() }.should raise_error(Chef::Exceptions::Mount) |
56 | 64 | end |
57 | | - |
| 65 | + |
| 66 | + it "should raise an error if the mount device (uuid) does not exist" do |
| 67 | + @new_resource.device_type :uuid |
| 68 | + @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" |
| 69 | + status_findfs = mock("Status", :exitstatus => 1) |
| 70 | + stdout_findfs = mock("STDOUT", :first => nil) |
| 71 | + @provider.should_receive(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,stdout_findfs,@stderr).and_return(status_findfs) |
| 72 | + ::File.should_receive(:exists?).with("").and_return(false) |
| 73 | + lambda { @provider.load_current_resource() }.should raise_error(Chef::Exceptions::Mount) |
| 74 | + end |
| 75 | + |
58 | 76 | it "should raise an error if the mount point does not exist" do |
59 | 77 | ::File.stub!(:exists?).with("/tmp/foo").and_return false |
60 | 78 | lambda { @provider.load_current_resource() }.should raise_error(Chef::Exceptions::Mount) |
61 | 79 | end |
62 | 80 |
|
63 | | - |
64 | 81 | it "should set mounted true if the mount point is found in the mounts list" do |
65 | 82 | @provider.stub!(:shell_out!).and_return(OpenStruct.new(:stdout => '/dev/sdz1 on /tmp/foo')) |
66 | 83 | @provider.load_current_resource() |
|
175 | 192 | @provider.should_receive(:shell_out!).with("mount -t ext3 -o rw,noexec,noauto /dev/sdz1 /tmp/foo") |
176 | 193 | @provider.mount_fs() |
177 | 194 | end |
| 195 | + |
| 196 | + it "should mount the filesystem specified by uuid" do |
| 197 | + @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" |
| 198 | + @new_resource.device_type :uuid |
| 199 | + @stdout_findfs = mock("STDOUT", :first => "/dev/sdz1") |
| 200 | + @provider.stub!(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,@stdout_findfs,@stderr).and_return(@status) |
| 201 | + @stdout.stub!(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}") |
| 202 | + @provider.should_receive(:shell_out!).with("mount -t #{@new_resource.fstype} -o defaults -U #{@new_resource.device} #{@new_resource.mount_point}") |
| 203 | + @provider.mount_fs() |
| 204 | + end |
178 | 205 |
|
179 | 206 | it "should not mount the filesystem if it is mounted" do |
180 | 207 | @current_resource.stub!(:mounted).and_return(true) |
|
0 commit comments